Stream: git-wasmtime

Topic: wasmtime / PR #7177 cranelift: Consider functions with TL...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 18:55):

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 the ra register and before returning from the current function we would not restore the correct ra 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 the is_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.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 18:55):

afonso360 requested fitzgen for a review on PR #7177.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 18:55):

afonso360 requested wasmtime-compiler-reviewers for a review on PR #7177.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 19:11):

afonso360 updated PR #7177.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 19:32):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 19:33):

alexcrichton has enabled auto merge for PR #7177.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 06 2023 at 20:23):

alexcrichton merged PR #7177.


Last updated: Nov 22 2024 at 17:03 UTC