This is an archive of the discontinued LLVM Phabricator instance.

UBSan ␇ runtime
AbandonedPublic

Authored by jfb on Apr 1 2020, 7:48 AM.

Details

Reviewers
None
Summary

Yes, this is April 1st and the patch isn't particularly serious.

There is a ␇ UBSan runtime available. It is named in honor of Bell Labs (who
gave us the C programming language and Undefined Behavior), the ASCII "bell"
character (value 07), and famed violinist Joshua Bell. It is not related to
the city of Bell in California. This runtime will emit sound, most traditionally
the terminal's bell sound, when undefined behavior occurs.

To use the minimal runtime, add -fsanitize-bel-runtime to the clang command
line options. For example, if you're used to compiling with
-fsanitize=undefined, you could enable the minimal runtime with
-fsanitize=undefined -fsanitize-bel-runtime.

When combined with -fsanitize-recover=undefined, the ␇ runtime will simply
chime on Undefined Behavior without killing the program for each chime. To avoid
Pavlovian effects, the ␇ runtime uses Advanced Compiler Techniques called
"heuristics" to avoid chiming too often at the same location.

On macOS, the ␇ runtime will helpfully announce what specific undefined behavior
you've encountered, and then taunt you.

Diff Detail

Unit TestsFailed

Event Timeline

jfb created this revision.Apr 1 2020, 7:48 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 1 2020, 7:48 AM
Herald added subscribers: Restricted Project, cfe-commits, ributzka and 4 others. · View Herald Transcript
jfb edited the summary of this revision. (Show Details)Apr 1 2020, 7:49 AM
jfb added a subscriber: regehr.Apr 1 2020, 8:02 AM
regehr added a comment.Apr 1 2020, 8:28 AM

Sorry but I don't think this can land until it has options for sending sanitizer output to Slack channels and SMS numbers.

lebedev.ri added inline comments.
compiler-rt/lib/ubsan_bel/ubsan_bel_handlers.cpp
40–42

I'm not sure we should be introducing randomness into UB handler.
I think what this instead should do, is attach gdb to the process and fix the UB-invoking instructions.

jfb marked an inline comment as done.Apr 1 2020, 9:16 AM
jfb added inline comments.
compiler-rt/lib/ubsan_bel/ubsan_bel_handlers.cpp
40–42

Hmm, should it be sudo-random to ensure that rm -rf / works?

What is gdb? Is it like lldb but not as low-level?

jfb abandoned this revision.Aug 26 2020, 8:38 AM

I don't think the world is ready for this.