-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Backtracing] Add improved backtracing support for Swift crashes #64028
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
@swift-ci Please test |
Contributor
Author
|
The individual pieces of this have already been reviewed as a set of stacked PRs:
|
f8d18e5 to
19c212e
Compare
When a Swift program crashes, we should catch the crash and execute the external backtracer. rdar://105391747
In order for the runtime PR to work as a separate PR, it does need a little bit of code in the `_SwiftBacktracing.h` header in SwiftShims. rdar://105391747
We really, really shouldn't be running the external backtracer for setuid binaries. It's just too dangerous. So don't do that. And if someone tries to force us, emit a warning. rdar://105391747
If we find signal handlers already installed, leave them alone. rdar://105391747
Need to change this to `swift_copyAuxiliaryExecutablePath()`. rdar://105391747
Adds a new swift_Backtracing library, with a corresponding _Backtracing module, to the build. Also add some tests. This is not public API at this point, but will be used by the external backtracing program, `swift-backtrace`. rdar://104336548
We need to enable MASM/MARMASM and we need to add a get-cpu-context.asm file for it to build. rdar://104336548
The correct name for the runtime library appears to be CRT, not MSVCRT. rdar://104336548
Some of the `TARGET` and `os()` conditionals needed to be updated. rdar://104336548
Linux doesn't have `issetugid()`, so use `getauxval(AT_SECURE)` there instead. rdar://105391747
Accidentally wrote `thread_resume()` instead of `thread_suspend()`. rdar://105391747
Removed some unnecessary memory rebinding. Made `CFString` conversion slightly more efficient. Provide the `SharedCacheInfo` fields everywhere, but make it optional all over as well. rdar://104336548
Just use `UInt` for `Address`. This is still the subject of some discussion on the forums, but I haven't decided precisely what to do about it and `UInt` makes sense for now. This also necessitated some casts elsewhere. Improve some comments. Made `limit` robust against silly negative values. A couple of formatting fixes. Don't bother supporting the macOS 10.12.2 SDK as Xcode now supports a minimum of 10.13.
9a6d247 to
e2aa440
Compare
26f36a3 to
4cbc511
Compare
iOS doesn't have <libproc.h>. We don't need it anyway there. rdar://104336548
ce97f92 to
4476a76
Compare
rdar://104336548
Once the API has gone through Swift Evolution, we will want to implicitly import the _Backtracing module. Add code to do that, but set it to off by default for now. rdar://105394140
This is Swift's external backtracer. It's written in Swift, and it's responsible for generating nice backtraces when Swift programs crash. It makes use of the new `_Backtracing` library, which is also (mostly, aside from some assembly language) implemented in Swift. rdar://103442000
Fixed the colours so that they work with all of the default Terminal presets. Also changed things so that when colour is off, we only use ASCII characters in our source code displays. rdar://105452194
The name of the C library on Windows is CRT, apparently. rdar://105452194
…cer. Add some discussion of how the new external backtracer works and what options are available. rdar://105394365
…cOS. Added a list of handled signals and some notes on what the runtime will do if it finds signal handlers already configured. rdar://105394365
Some symbolication frameworks have a symbol cache; we probably don't want to use that for test cases, to avoid running into problems where the cache holds stale information. rdar://105409147
ca7ca18 to
7fd02a9
Compare
Contributor
Author
|
@swift-ci Please test |
9e41d45 to
13af9c6
Compare
Contributor
Author
|
Re-created PR as #64100 after rebasing on main to solve conflict (it wasn't just a simple conflict; other files needed editing too). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds on-crash backtracing for Swift programs on macOS.