-
Notifications
You must be signed in to change notification settings - Fork 129
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
[PLAT-7335] Use Function Starts for symbolication #1214
Merged
Merged
Conversation
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
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
nickdowell
commented
Oct 20, 2021
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
nickdowell
force-pushed
the
nickdowell/function-starts
branch
from
October 20, 2021 15:55
68007b7
to
7ad6212
Compare
nickdowell
force-pushed
the
nickdowell/function-starts
branch
from
October 28, 2021 07:32
7ad6212
to
2128592
Compare
kattrali
approved these changes
Oct 28, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool - were you aiming for adding and removing exactly the same number of lines though??
kstenerud
requested changes
Oct 28, 2021
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_Symbolicate.c
Outdated
Show resolved
Hide resolved
kstenerud
approved these changes
Oct 28, 2021
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.
Goal
Prevent incorrect function names appearing in stack traces.
The symbols found by
dladdr()
andbsg_ksdldladdr()
can be very misleading when run against binaries that have a mix of functions with and without symbols.dladdr()
andbsg_ksdldladdr()
scan through the symbol table looking for the symbol with highest address that precedes the instruction address. The symbol table does not contain information about the sizes of the functions the symbols relate to.For an instruction address inside a hidden function, the symbol returned will be that of a function that precedes it in memory.
This can result in a nonsensical looking stack trace if a dSYM has not been uploaded to Bugsnag.
If a dSYM has been uploaded, the back-end performs its own (more accurate) symbolication and the nonsensical looking stack trace will not be seen.
Design
The Function Starts list, which is in the
__LINKEDIT
segment of binaries built with Xcode 4 and later, describes the addresses of all the functions in the binary, whether hidden or not, and can be used to improve accuracy by:Changeset
bsg_ksdldladdr()
has been replaced withbsg_symbolicate()
andstruct bsg_symbolicate_result
is now used throughout instead ofDl_info
... Because the behaviour no longer matches that ofdladdr()
, it could be confusing to continue using the existing function name or struct.Note: the stack frame's
symbolAddress
is now subtly different, containing the address of the function rather than that of the closest symbol found. This should allow the back-end to symbolicate more accurately using the system dSYMs.Uses
CALL_INSTRUCTION_FROM_RETURN_ADDRESS
to improve accuracy when symbolicating handled errors, following the logic inbsg_ksbt_symbolicate()
used for unhandled errors.Testing
Existing E2E scenarios and unit tests (
BugsnagStackframeTest
andBugsnagThreadTests
) validate the symbolication results, and continue to pass. See this full run.An E2E test on another project that incorporates
bugsnag-cocoa
has verified that invalid function names no longer appear in stack traces.Manually tested on 32-bit armv7 device to verify that symbolication works there (for thumb instructions.)
Tested performance of
bsg_kscrash_i_onCrash()
and found that this change has little to no impact - adding a millisecond or two to the 150ms measured on an iPad3,1