-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix stack pointer retrieval in jl_backtrace_from_here #42585
Conversation
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; |
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 1: Take the pointer after grow, to avoid invalidation.
bt_entry->uintptr = call_ip; | ||
if (sp) | ||
sp[n] = thesp; | ||
n++; |
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]
where bt_data[n]
contains the call IP. It makes filtering out invalid stack pointers easy (see Base._reformat_sp
). Previously, it was stored at the beginning of the extended entry.
All calls to jl_unw_stepn
pass sp = NULL
expect the one from jl_backtrace_from_here
. So, I think this is a NFC.
$ git grep 'jl_unw_stepn('
src/stackwalk.c:static int jl_unw_stepn(bt_cursor_t *cursor, jl_bt_element_t *bt_data, size_t *bt_size,
src/stackwalk.c: jl_unw_stepn(&cursor, bt_data, &bt_size, NULL, maxsize, 0, &pgcstack, 1);
src/stackwalk.c: jl_unw_stepn(&cursor, bt_data, &bt_size, NULL, maxsize, skip + 1, &pgcstack, 0);
src/stackwalk.c: have_more_frames = jl_unw_stepn(&cursor, (jl_bt_element_t*)jl_array_data(ip) + offset,
src/stackwalk.c: jl_unw_stepn(&cursor, bt_data, &bt_size, NULL, maxsize, 0, &pgcstack, 1);
After e4a1edd,
from
I'll just roll it back for now. |
Hmm... The failure in win32 seems to be a real one: https://build.julialang.org/#/builders/9/builds/4162/steps/5/logs/stdio
i.e., As a reference, the version without |
The failures in FreeBSD seem irrelevant https://build.julialang.org/#/builders/78/builds/5229. It passes the backtrace test. |
I thought 3f8868a was simply needed if we want to ensure we the test would pass even if we were getting the wrong answer from the intermediate functions. Though either answer seems almost correct for what is expected of the stack pointer. |
I was getting the failure in all platforms without 3f8868a. In linux64 https://build.julialang.org/#/builders/69/builds/6083/steps/5/logs/stdio
In win64 https://build.julialang.org/#/builders/65/builds/5392
In win32 https://build.julialang.org/#/builders/9/builds/5488
In these cases, Since Is it OK to pull this as-is or do you want to investigate this further? |
Perhaps it would be |
This reverts commit 3f8868a.
Ah, good point. Let's see if it works. |
Hmm... win64 failed but I don't think if it's relevant https://build.julialang.org/#/builders/65/builds/5439 (but re-starting it to be sure) FreeBSD failure seems irrelevant. |
If you rebase this PR branch on the latest master, that will fix the FreeBSD test failures. Also, I noticed that the master branch of your fork is behind the master branch of JuliaLang/julia. I'd recommend fast-forwarding the master branch of your fork so that it is up-to-date with the master branch of JuliaLang/julia. |
Thanks, I didn't realize that this branch is rather behind the I always start a branch from whatever the |
Ah, I thought you were starting feature branches off of the |
Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 455236e)
Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 455236e)
Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 455236e)
…) (#43241) * Fix stack pointer retrieval in jl_backtrace_from_here (#42585) Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 455236e) * Avoid using call-site `@noinline`
Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
It seems
jl_backtrace_from_here
with thereturnsp
flag set was broken. This patch adds a few fixes and a test.