-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix stack pointer retrieval in jl_backtrace_from_here #42585
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
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2635252
Take pointer after grow
tkf 2990b77
Align stack and instruction pointers
tkf 6ca4eb5
Can we just always (up)cast pointers to UInt64?
tkf ac3468d
Alternative/proper fix; use WORD_SIZE
tkf 458cb89
Actually allocate nbytes
tkf 7a338ae
Skip closure-based tests on ARM etc.
tkf 4eb674d
Don't use closure
tkf e4a1edd
Pass a function as Any
tkf fcae973
Further simplify llvmcall
tkf a935c7a
Revert "Further simplify llvmcall"
tkf d284a34
Revert "Pass a function as Any"
tkf b51e198
Move _reformat_sp to test suite and fix the typos
tkf 24c2aa1
Use llvm.frameaddress
tkf 03e5129
Merge branch 'master' into fix-sp
tkf 4fcda37
Use inferencebarrier to be extra sure
tkf 9270661
Revert "Use inferencebarrier to be extra sure"
tkf 778def1
Revert "Use llvm.frameaddress"
tkf d0cedca
Merge branch 'master' into fix-sp
tkf 6194475
Use llvm.frameaddress
tkf 0a07e32
Use Int32 as LangRef mentions
tkf 9e80b08
Update test/backtrace.jl
tkf 715c673
Call llvm.frameaddress using Intrinsics.llvmcall
tkf de860b2
Directly invoke llvmcall in withframeaddress
tkf e37c0d5
Put back missing `@eval`
tkf 3f8868a
Add dummy frames
tkf 4b6a27f
Revert "Add dummy frames"
tkf 66ff7e9
Check `sp[1] < ptr1`, not `sp[2] < ptr1`
tkf 4c62333
Merge branch 'master' into fix-sp
tkf df9d96d
Merge branch 'master' into fix-sp
tkf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,8 +114,6 @@ static int jl_unw_stepn(bt_cursor_t *cursor, jl_bt_element_t *bt_data, size_t *b | |
from_signal_handler = 0; | ||
continue; | ||
} | ||
if (sp) | ||
sp[n] = thesp; | ||
// For the purposes of looking up debug info for functions, we want | ||
// to harvest addresses for the *call* instruction `call_ip` during | ||
// stack walking. However, this information isn't directly | ||
|
@@ -168,6 +166,8 @@ static int jl_unw_stepn(bt_cursor_t *cursor, jl_bt_element_t *bt_data, size_t *b | |
} | ||
} | ||
bt_entry->uintptr = call_ip; | ||
if (sp) | ||
sp[n] = thesp; | ||
n++; | ||
} | ||
// NOTE: if we have some pgcstack entries remaining (because the | ||
|
@@ -259,8 +259,8 @@ JL_DLLEXPORT jl_value_t *jl_backtrace_from_here(int returnsp, int skip) | |
jl_array_grow_end(ip, maxincr); | ||
uintptr_t *sp_ptr = NULL; | ||
if (returnsp) { | ||
sp_ptr = (uintptr_t*)jl_array_data(sp) + offset; | ||
jl_array_grow_end(sp, maxincr); | ||
sp_ptr = (uintptr_t*)jl_array_data(sp) + offset; | ||
Comment on lines
261
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix 1: Take the pointer after grow, to avoid invalidation. |
||
} | ||
size_t size_incr = 0; | ||
have_more_frames = jl_unw_stepn(&cursor, (jl_bt_element_t*)jl_array_data(ip) + offset, | ||
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Fix 2: set
sp[n]
wherebt_data[n]
contains the call IP. It makes filtering out invalid stack pointers easy (seeBase._reformat_sp
). Previously, it was stored at the beginning of the extended entry.All calls to
jl_unw_stepn
passsp = NULL
expect the one fromjl_backtrace_from_here
. So, I think this is a NFC.