Skip to content

win32: ignore remaining benign debug/EH notifications under -bt - #95

Open
Code-newWorld wants to merge 2 commits into
vlang:thirdparty-windows-amd64from
Code-newWorld:win32-ignore-remaining-benign-debug-exceptions
Open

Code-newWorld wants to merge 2 commits into
vlang:thirdparty-windows-amd64from
Code-newWorld:win32-ignore-remaining-benign-debug-exceptions

Conversation

@Code-newWorld

Copy link
Copy Markdown

Summary

  • Extend the existing 0002 VEH allowlist so TCC -bt also continues on remaining first-chance debugger/EH notifications: DBG_PRINTEXCEPTION_WIDE_C (OutputDebugStringW / 0x4001000A), DBG_RIPEXCEPTION, SetThreadName (0x406D1388), and Microsoft C++ EH (0xE06D7363).
  • Ship the rebuilt lib/bt-exe.o. V links this object via -bt; patch text alone does not change already-built compilers or user programs.
  • Access violation and other real faults stay fatal.

0002 already ignores ANSI OutputDebugStringA (0x40010006). The Wide path still hit cpu_exception_handler's default and exited 255 with caught exception 4001000a.

Test plan

  • tcc -bt + OutputDebugStringW exits 0 (no RUNTIME ERROR)
  • tcc -bt + null dereference still reports invalid memory access and exits non-zero
  • After pull, rebuild v.exe so the compiler process itself picks up the new bt-exe.o

Note: this PR does not repair the pre-existing corrupt 0005 / 0006 / 0008 patches in build.ps1. Daily users only need the new bt-exe.o.

wangyongzhi and others added 2 commits September 17, 2026 16:44
0002 only continues on OutputDebugStringA (0x40010006). The same VEH
still treats OutputDebugStringW (0x4001000A), debugger RIP, SetThreadName,
and MS C++ EH as fatal. Ship the rebuilt bt-exe.o so -bt programs survive
those first-chance notifications; real faults stay fatal.

Co-authored-by: Cursor <cursoragent@cursor.com>
CI staged-preflight marked the bundle ineligible because build.ps1,
winnt.h, and bt-exe.o changed while bundle-manifest.json still declared
the pre-0010 sha256s. Align those three digests with the committed blobs.

Co-authored-by: Cursor <cursoragent@cursor.com>

@medvednikov medvednikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 9cbf2a20a107885f1b4f474cc690f4699ec51b89, excluding CI results.

[P2] Rebuild the native libtcc.dll handler as well

The delivered binary fix covers newly linked executables, but not native -bt -run execution or libtcc clients. This PR replaces lib/bt-exe.o while leaving the bundled libtcc.dll unchanged. These contain separate copies of the handler: lib/bt-exe.c includes tccrun.c for linked executables, whereas libtcc.c compiles it into libtcc, whose bt_link() installs its own exception handler for in-memory execution. Updating the external object does not update that handler.

Consequently, the native execution path retains the old behavior for these notifications even after this bundle update. A Windows regression case to cover is tcc.exe -g -bt10 -run ods.c, with:

#include <windows.h>
int main(void) {
    OutputDebugStringW(L"probe");
    return 0;
}

Please rebuild and ship the native libtcc.dll with patch 0010 too, update its manifest digest, and check this in-memory execution case alongside the linked-EXE test. This is an incomplete delivery of the fix, not a claim that the PR newly introduced the old failure.

Validation: the new patch's SHA-256 matches its manifest entry, Git accepts its syntax, and it applies to a fixture containing the relevant pinned TinyCC source context plus patch 0002. An isolated C harness for the patched handler passed all five allowlisted-code checks and six fatal-code checks, including access violation, stack overflow, divide-by-zero, and unknown exceptions. The added cases use EXCEPTION_CONTINUE_SEARCH, preserving downstream exception handling. These were source-level checks with mocked runtime hooks; I did not run Windows binaries or reproduce the -run case on Windows. The pre-existing patch 0005/0006/0008 issues are outside this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants