Skip to content

[lldb][swift] Mark async unwinding plans as SourcedFromCompiler #9820

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

Conversation

felipepiovezan
Copy link

LLDB always attempts to check other unwinding plans when an unwind plan produces a CFA == 0. It does so because it doesn't distinguish the case where the plan truly produced the end of the stack versus the case where the plan was faulty.

We need a mechanism to disable this for swift async plans: if the language runtime constructs such a plan, then that plan will correctly identify the bottom of the stack. Checking other plans is harmless in non-async settings (they would just produce the same backtrace), but it is harmful for async virtual backtraces, as a "regular" unwind plan would produce a real backtrace if it were asked to start from the top of the stack (which would happen in short backtraces).

Until such mechanism exists, we can work around the issue by claiming swift async plans are "sourced from compiler", which seem to disable the fallback mechanism because plans sourced from the compiler are considered the most reliable plans.

rdar://142683622

LLDB always attempts to check other unwinding plans when an unwind plan
produces a CFA == 0. It does so because it doesn't distinguish the case
where the plan truly produced the end of the stack versus the case where
the plan was faulty.

We need a mechanism to disable this for swift async plans: if the
language runtime constructs such a plan, then that plan will correctly
identify the bottom of the stack. Checking other plans is harmless in
non-async settings (they would just produce the same backtrace), but it
is harmful for async virtual backtraces, as a "regular" unwind plan
would produce a real backtrace if it were asked to start from the top of
the stack (which would happen in short backtraces).

Until such mechanism exists, we can work around the issue by claiming
swift async plans are "sourced from compiler", which seem to disable the
fallback mechanism because plans sourced from the compiler are
considered the most reliable plans.

rdar://142683622
Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

Since this only affects async unwind plans the risk seems to be limited.

@felipepiovezan
Copy link
Author

@swift-ci test

Copy link

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

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

Felipe and I discussed this last week, it's not the most obvious way of achieving what he needs here, but I didn't think it was worth adding yet another method to UnwindPlan which says substantially the same. This looks good to me.

@adrian-prantl adrian-prantl merged commit 9c7f25b into swiftlang:swift/release/6.1 Jan 13, 2025
3 checks passed
@felipepiovezan felipepiovezan deleted the felipe/fix_short_async_backtraces branch January 13, 2025 22:46
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