forked from bugsnag/bugsnag-cocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Strip top bits from pointers before reading memory contents
In the new Xcode 10 build system, Swift object register values have the top bit used as a flag. This change strips the flag while not losing anything relevant to us in our quest to see error messages for assertion failures. This technique does not capture messages which are less than 16 characters, as short strings are stored as raw char arrays on the stack rather than being allocated. (See WWDC 2018 bugsnag#401 for more info on new string optimizations) While it is possible to check for char arrays as well as pointers when searching for notable address values, sweeping up local variables has a likely chance of capturing unintended data as well from the surrounding code, some of which may be sensitive. It is also not guaranteed that the value would still be on the stack after the message is logged, so it is possible to get only unrelated string values as the message. In the current Swift stdlib, the following messages passed to fatalError, preconditionFailure, and precondition (and their internal func counterparts) are less than 16 characters: * empty string * `unavailable` * `not implemented` * `abstract method` * `unknown value` * `invalid count` (where a dictionary contains < 0 items(?)) * `invalid index` (where a dictionary ceases to be a dictionary) * `don't touch me` (from SpriteKit) * `close() failed` (from the private Subprocess implementation) The vast majority have more meaningful messages. Reference: * https://asciiwwdc.com/2018/sessions/401 Fixes bugsnag#318
- Loading branch information
Showing
6 changed files
with
47 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
PODS: | ||
- Bugsnag (5.15.6) | ||
- Bugsnag (5.17.0) | ||
|
||
DEPENDENCIES: | ||
- Bugsnag (from `../../..`) | ||
|
||
EXTERNAL SOURCES: | ||
Bugsnag: | ||
:path: ../../.. | ||
:path: "../../.." | ||
|
||
SPEC CHECKSUMS: | ||
Bugsnag: ff5f5e3059e6a9c9d27a899f3bf3774067553483 | ||
Bugsnag: 2d163d2f4c7acdb9bbcfc7a938c646f3aa39f566 | ||
|
||
PODFILE CHECKSUM: 4d026fb83571f098c9fb4fa71c1564c72c55ab1a | ||
|
||
COCOAPODS: 1.4.0 | ||
COCOAPODS: 1.5.3 |
This file contains 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
12 changes: 12 additions & 0 deletions
12
features/fixtures/ios-swift-cocoapods/iOSTestApp/scenarios/SwiftAssertion.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
|
||
class SwiftAssertion: Scenario { | ||
override func startBugsnag() { | ||
self.config.shouldAutoCaptureSessions = false; | ||
super.startBugsnag() | ||
} | ||
|
||
override func run() { | ||
fatalError("several unfortunate things just happened") | ||
} | ||
} |