Mocked up a quick PoC to test whether LLVM's ubsan would work with 
Emscripten.

You can find it 
here: https://gist.github.com/hackcasual/7de2f357714505061506df01923f99cd

Compile and run like so:

c:\dev>em++  testub.cc -fsanitize=signed-integer-overflow && node a.out.js
Overflow happened 2147483647 + 1 @testub.cc

em++ doesn't seem to hook up the ubsan library, and a cursory investigation 
of it in the LLVM source leads me to believe it might be challenging to get 
working with Emscripten. Turning it on for my large, private code base 
(~10MB js for the test suite) showed less than 10 methods needing to be 
defined, so it's probably easier to re-implement the runtime library 
specifically for emscripten. This would also allow for stuff like debugger 
on UB, or printing Javascript stack traces. For full ubsan support, the 
JSBackend would need to implement the @llvm.objectsize intrinsic, but I 
believe only -fsanitize=object-size depends on it.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to