-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Backtracing] Add improved backtracing support for Swift crashes #64100
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
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
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.
iOS doesn't have <libproc.h>. We don't need it anyway there. rdar://104336548
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
While I was doing this, it turns out Saleem was fixing things to avoid having to patch the Windows include directories, which is awesome but necessitates an extra change to the backtracing stuff to make the build not fail on Windows. rdar://105409147
The Linux Swift compiler is ICEing when building _Backtracing, while Windows still needs some tweaks. In order to land this sooner, disable this code except for macOS.
There was a missing "e" in "movl (%esp), %edx".
Added some extra code to AddSwiftStdlib.cmake so executable targets can specify target SDKs the same way libraries currently can. Updated the Backtracing targets to specify just OS X for now.
Implicit imports were off for library builds already, but we need them off for executable builds too, otherwise we have problems with _StringProcessing.
For some reason we don't see the dyld frames in CI. That's fine, don't check for them. Also turn NotImportedByDefault off for Windows as it needs a better shell than the support provided there.
@swift-ci Please test |
The individual pieces of this have already been reviewed as a set of stacked PRs:
|
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.