Repository navigation
A fatal exception says where it happened: library+offset in last-fault.txt and on stderr (Windows) - #1266
Merged
Conversation
…t.txt and on stderr (Windows)
… they are not there yet
…ault whose stack cannot be walked still leaves its place
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A fatal exception on Windows ends the app with its code and, for a window, a 64-byte record that holds the code and nothing else. Neither says where it happened. A launch from a script gets no Windows report either (it inherits an error mode in which none is written), and a fault in a launch's first half second comes before the profile's record can be written at all.
This makes the app say the place itself, with no debugger attached.
flowchart LR F[exception] -->|"only with OPENCODE_RUNE_FAULT_FIRST_CHANCE=1"| V[vectored handler: 'first chance' line] F --> W{Windows walks the stack<br/>to the thread's start} W -->|reached| H[unhandled_filter] W -->|"not reached: the process ends, no call"| X[exit with the code] H --> R[record_fault: last-exit.bin, code only] H --> P[place::write: 'fatal exception' line] V --> L["<logs>/last-fault.txt + stderr"] P --> L H --> T[TerminateProcess with the code]What a fault leaves, in
<logs>/last-fault.txtand on stderr (from a run of this branch's Windows build, a read of address 8 made in a system library from outside):last_exit/place.rs, called by the existing unhandled-exception filter after the 64-byte record, on the faulting thread.library+offset. An offset becomes a function with the build's debug file.RtlPcToFileHeaderand named by the file its image is mapped from (NtQueryVirtualMemory); the frames come fromRtlCaptureStackBackTrace. After a stack overflow only the first line is written: the walk needs stack that thread no longer has.OPENCODE_RUNE_FAULT_FIRST_CHANCE=1a vectored handler writes the same fields markedfirst chancefor0xC0000005,0xC000001D,0xC0000409and0xC00000FD, at most eight a process, before any stack is walked. It is a diagnostic arm: a first-chance exception may be one some frame then handles. Unset, no handler is installed.Shown on this branch's Windows x64 build
A fault made from outside in a running app: one thread started in its process, no debugger, nothing written into it. Then the exit code (all 32 bits), stderr and
<logs>/last-fault.txtwere read back.888ca1af63, Windows x64 artifact of PR CI run45706128174(based on397ae99209, Rune pind5c7a5ad2; PR CI compiled macOS, Windows x64, Windows arm64 and Linux x64 plus guardrails, with Linux arm64 skipped).0.0.0-dev-490, commit5381921190(Rune pin4d8df909), release run45613776234.last-fault.txtntdll0xC0000005fatal exception 0xC0000005 (read of 0x…08) … at ntdll.dll+0x16C451, 3 framesntdll0xC0000005+0x3119)0x80000003fatal exception 0x80000003 … at opencode-desktop.dll+0x3119, 3 frames0x80000003ud2in the middle of a function of the app's library (+0x2162): a stack Windows cannot walk0xC000001D0xC000001Dfirst chance: exception 0xC000001D … at opencode-desktop.dll+0x21620xC000001Dntdll0xC0000005first chancerecord, then thefatal exceptionrecordntdll, on before build0.0.0-dev-490(5381921190, run45613776234)0xC0000005scripts/web.ps1 -Check) on head888ca1af63: exit 0 (Finished dev profile … in 1m 24s;web clock: 1095 files in 49 crates, no std::time::Instant or SystemTime::now).2e366c0613): merged withoutdevtaken in after fix(deps): pin rune to 5342f14d (93 commits): window buttons on Wayland without server decorations, smaller backdrop blur copies #1257 (affe876fca, Rune pin5342f14d1) landed (branch head888ca1af63was based on397ae99209, Rune pind5c7a5ad2); no files overlapped with the interveningdevcommits (onlylast_exit/changed). First built with the new pin (5342f14d1) by run45715407465(check build chore: check build of dev 2e366c0613 (NEVER MERGE) #1280, head53abad895a), completed green (guardrails, macOS, Windows x64 and arm64, Linux x64; Linux arm64 skipped).