Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(coroutine): improve panic handling with igop-style stack traces #487

Closed
wants to merge 1 commit into from

Conversation

aofei
Copy link
Member

@aofei aofei commented Jan 14, 2025

When spx runs in an igop environment, we need to preserve the original stack info from panics to help with debugging. This change adds support for igop-style panic errors that carry stack info.

When spx runs in an igop environment, we need to preserve the original
stack info from panics to help with debugging. This change adds support
for igop-style panic errors that carry stack info.

Signed-off-by: Aofei Sheng <[email protected]>
@@ -80,7 +75,9 @@ func (p *Coroutines) CreateAndStart(start bool, tobj ThreadObj, fn func(me Threa
p.mutex.Unlock()
p.sema.Unlock()
if e := recover(); e != nil {
if e != ErrAbortThread {
if pe, ok := e.(iGopPanicError); ok {
panic(pe.Error() + "\n" + string(pe.Stack()))
Copy link
Member

@xushiwei xushiwei Feb 9, 2025

Choose a reason for hiding this comment

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

why not to format error info in outer side (at where recover this error)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue isn't about formatting error info. When user code panics, the panic/recover mechanism here catches and re-throws it, which creates a new stack trace starting from the re-panic point. This makes it impossible to trace back to the original panic location in user code.

@nighca
Copy link
Collaborator

nighca commented Feb 11, 2025

May be related to #494

@aofei
Copy link
Member Author

aofei commented Feb 13, 2025

This PR has been abandoned in favor of #495 since we don't want spx to be aware of igop.

@aofei aofei closed this Feb 13, 2025
@aofei aofei deleted the coro-panic branch February 13, 2025 01:10
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.

3 participants