afonso360 opened PR #7177 from afonso360:abi-tls-leaf
to bytecodealliance:main
:
:wave: Hey,
@bjorn3 reported an issue with TLS values in the RISC-V backend, when testing it with cg_clif. This presented as a segfault running the cg_clif testsuite.
Digging into it, it looks like we would call the
elf_tls_getaddr
function, which would clobber thera
register and before returning from the current function we would not restore the correctra
value from the stack. This would cause the function to recurse back into the middle of itself and cause a segfault.This function met all criteria for us to avoid emitting a prologue and epilogue sequence, that would correctly restore the
ra
value. The check that was failing here is theis_leaf
check. It assumes that a function will only call other functions if it contains any signatures itself.This PR adds an additional check for TLS values, and assumes that if such a value exists we will be calling a function to retrieve it's address. This is not necessarily true, but it is a good conservative estimate.
More importantly I don't think this fully addresses the issue. I think we can still have a similar issue if we decide to use a libcall instead of native instruction during lowering. I'm not entirely sure how to fix that.
afonso360 requested fitzgen for a review on PR #7177.
afonso360 requested wasmtime-compiler-reviewers for a review on PR #7177.
afonso360 updated PR #7177.
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #7177.
alexcrichton merged PR #7177.
Last updated: Nov 22 2024 at 17:03 UTC