Skip to content

[Linux] Disable fatalError() backtraces when the runtime backtracer is active. #69613

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

Merged
merged 3 commits into from
Nov 9, 2023

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Nov 2, 2023

There's no need for fatalError() to try to generate its own backtraces when the runtime's backtracer is enabled. Not only is the code it uses more fragile but it also doesn't support async or inline frames and it can't look-up symbols properly either.

rdar://117470489

…s active.

There's no need for fatalError() to try to generate its own backtraces
when the runtime's backtracer is enabled.  Not only is the code it uses
more fragile but it also doesn't support async or inline frames and it
can't look-up symbols properly either.

rdar://117470489
The Runtime/backtrace test is a test of the fatalError() backtracer,
which gets turned off when we have the new backtracer enabled.  So,
to make this test work, we need to turn off the new backtracer.

rdar://117470489
@al45tair al45tair added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.10 labels Nov 2, 2023
@al45tair al45tair requested a review from a team as a code owner November 2, 2023 16:36
@al45tair
Copy link
Contributor Author

al45tair commented Nov 2, 2023

Explanation: Currently if a program terminates with an assertion failure or fatalError(), the assertion failure code in the Swift runtime tries to generate its own backtrace using libunwind and dlsym(). When the new backtracer that was added in 5.9 is also active, this is confusing because you get two backtraces, and on Linux the dlsym() call is a really poor way to do a symbol lookup so the first one you see has lots of <unavailable> symbols listed in it. The upshot is confusing output.
Original PR: #69570
Reviewed by: @mikeash
Resolves: rdar://117470489
Tests: There is a test of the fatalError() backtrace already, so that just gets updated to turn off the out-of-process backtracer, plus I updated one of the out-of-process backtracer tests to explicitly check that the fatalError() backtracer doesn't generate any output when it's enabled.

@al45tair
Copy link
Contributor Author

al45tair commented Nov 2, 2023

@swift-ci Please test

@al45tair
Copy link
Contributor Author

al45tair commented Nov 3, 2023

@swift-ci Please test Windows platform

1 similar comment
@al45tair
Copy link
Contributor Author

al45tair commented Nov 6, 2023

@swift-ci Please test Windows platform

@al45tair
Copy link
Contributor Author

al45tair commented Nov 8, 2023

@swift-ci Please test

When backtracing is disabled, don't try to refer to
`_swift_backtraceSettings`.

rdar://117470489
@al45tair al45tair force-pushed the eng/PR-117470489-5.10 branch from 6397cd4 to 9672193 Compare November 8, 2023 16:07
@al45tair
Copy link
Contributor Author

al45tair commented Nov 8, 2023

@swift-ci Please test

@al45tair al45tair merged commit e8ff3ba into swiftlang:release/5.10 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants