-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
probe-stack=inline-asm
generates wrong DWARF information
#83139
Comments
Please check with a more recent nightly version. I mildly recall hearing a similar issue which might have been fixed since. |
Upstream report: https://bugs.llvm.org/show_bug.cgi?id=49600 |
Tried with |
I've tried to fix this issue in llvm with this patch. After building |
Assigning Will be mentioned during today's meeting. @rustbot label -I-prioritize +P-critical |
discussed in T-compiler meeting. We plan to revert PR #77885 (or at least a portion of it) on beta before next week's release, in order to buy us more time to evaluate tradeoffs here. |
…7885-for-issue-83139, r=nagisa [stable] probe-stack=call everywhere again, for now. To buy time on issue 83139, revert effect of PR 77885: We will not conditionally enable probe-stack=inline-asm on LLVM 11+ anymore on any of our targets that opted into doing so on PR rust-lang#77885 (and were subsequently configured to do so in a fine grained manner on PR rust-lang#80838). After we resolve 83139 (potentially by backporting a fix to LLVM, or potentially by deciding that one cannot rely on the quality of our DWARF output in the manner described in issue 83139), we can change this back. cc rust-lang#83139
Issue priority downgraded as discussed during the team compiler meeting @rustbot label +P-high -P-critical |
discussed at team compiler meeting. A partial solution, addressing solely the case where the loop is unrolled, has landed in LLVM in https://reviews.llvm.org/D99579 We would probably be in favor of backporting D99579, even though it is only a partial solution to the problem here. |
A partial fix for rust-lang#83139
Include a backport for wrong DWARF information A partial fix for rust-lang#83139 r? `@cuviper` or `@nikic`
…in, for now. We had already reverted the change on stable back in PR rust-lang#83412. Since then, we've had some movement on issue rust-lang#83139, but not a 100% fix. But also since then, we had bug reported, issue rust-lang#84667, that looks like outright codegen breakage, rather than problems confined to debuginfo issues. So we are reverting PR rust-lang#77885 on stable and beta. We'll reland PR rust-lang#77885 (or some variant) switching back to an LLVM-dependent selection of out-of-line call vs inline-asm, after these other issues have been resolved.
…ark-Simulacrum Revert PR 77885 everywhere Change to probe-stack=call (instead of inline-or-call) everywhere again, for now. We had already reverted the change on stable back in PR rust-lang#83412. Since then, we've had some movement on issue rust-lang#83139, but not a 100% fix. But also since then, we had bug reported, issue rust-lang#84667, that looks like outright codegen breakage, rather than problems confined to debuginfo issues. So we are reverting PR rust-lang#77885 on stable and beta. We'll reland PR rust-lang#77885 (or some variant) switching back to an LLVM-dependent selection of out-of-line call vs inline-asm, after these other issues have been resolved.
A fix for this is available from 1.53 onwards (nightly and soon enough beta), and it's been backported to 1.52 stable. Closing the issue. If this is still happening please leave a comment and we'll reopen it! |
Note: the underlying issue has been fixed upstream, see llvm/llvm-project#48944 (comment).
Edit: actually #84667 / https://bugs.llvm.org/show_bug.cgi?id=50165 / llvm/llvm-project#49509 is still a problem |
@erikdesjardins You say that #84667 is still a problem, but that issue is closed. Should it be reopened? |
I should've been clearer: #84667 occurred due to a bug in LLVM codegen related to inline-asm stack probes. It is not a problem for current-day Rust users, because we disabled inline-asm stack probes. But the underlying LLVM bug still exists, which prevents us from enabling inline-asm stack probes. (I do not know if this means it should be reopened, presumably not, but hopefully this gives you enough to context to tell) |
I'm the author of
pprof-rs
, which is a library to perf rust programs by sampling backtraces in signal handler. After #77885 merged, it causesSegmentation Fault
. After investigating this bug, I found that it was caused by wrong DWARF information. In the old version ofrustc
,__rust_probstack
doesn't have DWARF information, so when a signal hits__rust_probstack
,_Unwind_Backtrace
will get a short backtrace (only containing the signal handler parts) but not break. However, after usinginline-asm
with a wrong DWARF information,_Unwind_Backtrace
will get a wrongcontext->ra
and dereferencing it will cause aSegmentation Fault
I tried this code:
I expected to see this happen: The dwarf information of this function works well
Instead, this happened: In the
probe-stack
part of codes, the dwarf information is wrong and_Unwind_Backtrace
will causeSegmentation Fault
by dereferencing an unexpected address (actually, the address is "0x0202020202020202").Part of
big_stack
assembly codes:The
DWARF
information about this part is quite simple:Though, the
probe-stack
part of this codes modified thersp
, the correspondingDWARF
information doesn't exist.Should I also file an issue in LLVM bugzilla? It seems to be a problem of LLVM. (The simplest way to fix it in my imagination is to use another register to loop over the stack, but not using
rsp
directly.)Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: