Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #10343
the test
nim cpp -r tests/exception/t9657
now works fornim cpp
and this PR re-enables it for nim cpp, see below for gory details of why it now worksin reply to #10343 (comment)
@Araq it's a little bit complicated so please read carefully:
after git bisect the underlying issue has been "accidentally" fixed in system refactorings #10559
that PR is large; after investigating the relevant fix is cstderr.write => cstderr.rawWrite, indeed, after that PR we can re-introduce the bug as follows:
=> that's just one of the reasons why we should ensure each commit should be buildable
here i ran the "run" part manually in git bisect inner loop because the test involves a hang; but more careful scripting would allow taking care of hangs (which is why it'd be nice to have a
nimbisect
tool taking care of all those difficulties; there's a small, finite number of them){.emit:"NIM_EXTERNC".}
was needed here because that commit happened before i fixed exportc to honor externcthe "accidental" (or not...) fix makes sense: it uses rawWrite instead of write to avoid raising (raiseEIO) inside
set_terminate
handlerthat's not the end of the story!
if i use a similar patch in git head to try to reproduce that bug in git head, it won't hang anymore, but will instead exit (with code !=0); after investigation, what happens is this:
{.emit: "throw e;".}
after__terminate
callsabort_message => abort
which sends a SIGABRT signal, which (because of registerSignalHandler) which callssignalHandler => rawWriteStackTrace => auxWriteStackTrace => addFrameEntry(s, tempFrames[j]) => add(s, f.filename)
prior to #12806 we had:
after instrumentation, turns out
y == nil
right before then hang, for whichy[i]
caused aEXC_BAD_ACCESS
(on OSX at least)the PR I had
the PR I had back when I wrote #10343 (comment) was a different approach, based on checking whether a CFile is valid using
fcntl
:I rebased it in timotheecour#324; even if not relevant anymore I think
fd_is_valid
is still useful, as a way to check whether a CFile is valid or not; not thatc_feof
does not work for that.summary
extended stacktrace for templates (treating templates as functions) would've helped diagnose this issue (refs:
nkComesFrom
seems deadcode (but used a lot); ok to remove? compilerdev#11 (comment)) since the stacktrace was pointing to an irrelevant frame in this casefix db_mysql getRow() when column is null error raised #12806 fixed 1 part of this issue (invalid nil dereference in
add
)system refactorings #10559 fixed another part of this issue (rawWrite vs write that throws)
fd_is_valid
(from old superseded fix for #10343 D20200623T225224 timotheecour/Nim#324) is useful and should be added somewhere