Skip to content
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

Strip top bits from pointers before reading memory contents #320

Merged
merged 1 commit into from
Nov 30, 2018

Commits on Nov 29, 2018

  1. 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 #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 #318
    kattrali committed Nov 29, 2018
    Configuration menu
    Copy the full SHA
    7094543 View commit details
    Browse the repository at this point in the history