WebAssembly / WebAssembly/wasi-sdk

SDK should support Undefined Behavior Sanitizer

Open
#552 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CMake
Stars
1.6k
Forks
237
Avg merge
18h 26m
Merged PRs (30d)
5

Description

Per https://github.com/llvm/llvm-project/issues/151015#issuecomment-3130203774.

Currently it results in a linker error:

$ /opt/wasi-sdk/bin/clang -fsanitize=undefined test.c
wasm-ld: error: /tmp/test-1cf416.o: undefined symbol: __ubsan_handle_pointer_overflow
wasm-ld: error: /tmp/test-1cf416.o: undefined symbol: __ubsan_handle_type_mismatch_v1
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is because sanitizer runtimes are turned off:

https://github.com/WebAssembly/wasi-sdk/blob/d05b57d2a21229fbc1d492d204057cf4751de697/cmake/wasi-sdk-sysroot.cmake#L82

I tried turning them on and that causes a cascade of failures, not the least a bunch of fuzzer headers appearing in include-all.c; some of which don't compile and some introduce new symbols. How should I proceed? I could add them to the find command with exclusions but there's like 15 new headers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect cmake/wasi-sdk-sysroot.cmake around the sanitizer-runtime setting and review how enabling it affects include-all.c. Reproduce the issue with the shown clang -fsanitize=undefined command, then verify that the SDK links successfully without the reported UBSan symbols or header-related failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, wasm
Domain
build-system, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.