Skip to content

preserve runtime SetTraceback behavior in tiny mode - #1064

Merged
mvdan merged 2 commits into
burrowers:masterfrom
Maremagnum:pr/tiny-settraceback
Aug 23, 2026
Merged

preserve runtime SetTraceback behavior in tiny mode#1064
mvdan merged 2 commits into
burrowers:masterfrom
Maremagnum:pr/tiny-settraceback

Conversation

@Maremagnum

Copy link
Copy Markdown
Contributor

Tiny mode empties runtime.setTraceback, but the function also updates runtime
state used outside human-readable traceback printing. On Windows that includes
WER crash-reporting behavior.

Stop removing runtime.setTraceback. Other tiny traceback-output cleanup is
unchanged.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a tiny-mode regression where garble emptied runtime.setTraceback, inadvertently changing non-traceback runtime behavior (notably Windows Error Reporting state toggled by debug.SetTraceback("wer")).

Changes:

  • Stop stripping the runtime.setTraceback function body in tiny mode so its non-printing side effects remain intact.
  • Add a Windows-only script test that asserts debug.SetTraceback("wer") clears SEM_NOGPFAULTERRORBOX (enabling WER behavior) even under -tiny.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
testdata/script/tiny-wer.txtar Adds a Windows-only regression test verifying debug.SetTraceback("wer") still flips WER-related process state under -tiny.
runtime_patch.go Removes the tiny-mode runtime patch that previously emptied runtime.setTraceback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread testdata/script/tiny-wer.txtar Outdated
@luantak

luantak commented Jul 14, 2026

Copy link
Copy Markdown
Member

@Maremagnum can you explain this more I'm a bit lost here

@mvdan

mvdan commented Aug 23, 2026

Copy link
Copy Markdown
Member

Thanks - the fix is correct, but I have a version of the test which is not windows-specific, which is much easier for us to run locally.

mvdan added 2 commits August 23, 2026 19:31
Tiny mode empties runtime.setTraceback, so debug.SetTraceback("crash") no
longer makes a fatal error crash the process. The test asserts that broken
behavior for now; the default build already gets it right.

The program re-execs itself rather than adding another script, so this
reuses the tiny build tiny.txtar already pays for.
runtime1.go's setTraceback was emptied on the grounds that tiny mode hides
tracebacks anyway, but the function does more than pick how much gets
printed. It stores traceback_cache, which gotraceback reads to decide
whether a fatal error crashes the process instead of exiting with status 2,
and on Windows GOTRACEBACK=wer enables Windows Error Reporting. Since
finishDebugVarsSetup routes GOTRACEBACK through it, tiny builds lost the
env var too, along with the crash-on-fatal rule for c-archive and c-shared.

Keeping it costs nothing measurable: a hello-world tiny build is 1343612
bytes either way, since the linker drops the body unless something
references debug.SetTraceback.
@mvdan
mvdan force-pushed the pr/tiny-settraceback branch from 7b2f2d6 to 27f4f7c Compare August 23, 2026 18:31
@mvdan
mvdan merged commit fface82 into burrowers:master Aug 23, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants