Skip to content

[Wasm] Disable use of returnaddress in exclusivity diagnostics #42097

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5765,7 +5765,9 @@ void IRGenSILFunction::visitBeginUnpairedAccessInst(
// in which case we should use the caller, which is generally ok because
// materializeForSet can't usually be thunked.
llvm::Value *pc;
if (hasBeenInlined(access)) {
// Wasm doesn't have returnaddress because it can't access call frame
// for security purposes
if (IGM.Triple.isWasm() || hasBeenInlined(access)) {
pc = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
} else {
auto retAddrFn =
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/Exclusivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#elif _MSC_VER
#include <intrin.h>
#define get_return_address() _ReturnAddress()
#elif defined(__wasm__)
// Wasm can't access call frame for security purposes
#define get_return_address() ((void*) 0)
#else
#error missing implementation for get_return_address
#define get_return_address() ((void*) 0)
Expand Down