Skip to content

fix: preserve Go stack traces for coroutine panics - #539

Open
eliotee wants to merge 1 commit into
yuin:masterfrom
eliotee:fix/coroutine-go-stack-trace
Open

fix: preserve Go stack traces for coroutine panics#539
eliotee wants to merge 1 commit into
yuin:masterfrom
eliotee:fix/coroutine-go-stack-trace

Conversation

@eliotee

@eliotee eliotee commented Sep 6, 2026

Copy link
Copy Markdown

Coroutine execution drops the Go stack trace when a Go callback panics, even with IncludeGoStackTrace enabled. Include the current Go stack in the recovered panic message before returning it through LState.Resume, coroutine.resume, or coroutine.wrap. Lua error objects retain their identity, including errors raised as *ApiError.

Fixes #529.

Validation:

  • The regression test fails on the original code for all three coroutine entry points with stack traces enabled.
  • Coverage includes both option values and Go panics, *ApiError panics, and Lua errors carrying table values.
  • make build
  • go test ./...
  • go test -race -skip '^TestLocalVarFree$' ./...

The full race run detects an existing race in TestLocalVarFree: countFinalizers reads numActiveUserDatas while a finalizer updates it atomically. The same race reproduces in an unmodified checkout of the base commit (75f4976); all other tests pass with the race detector.

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.

Coroutine thread does not return go stack trace during panics

1 participant