UndefinedBehaviorSanitizer
Hacker ApprovedRanked 4 of 6 sanitizers by recommenders
Compiler instrumentation that makes a program abort with a clear error at runtime when it hits undefined behavior, so bugs are caught instead of hidden.
Compiler instrumentation that makes a program abort with a clear error at runtime when it hits undefined behavior, so bugs are caught instead of hidden.
12 people gave an opinion
- recommend it
- 12
- criticize it
- 0
- approval share
- 100%
Recommended in 5 of 13 months
- November 2025: recommended
- December 2025: not recommended
- January 2026: recommended
- February 2026: recommended
- March 2026: not recommended
- April 2026: not recommended
- May 2026: recommended
- June 2026: not recommended
- July 2026: not recommended
- August 2026: not recommended
- September 2026: not recommended
- October 2026: recommended
- November 2026: not recommended (month in progress)
Why it carries the badge
- 12 people recommend itNeeds 10 or more, met.
- Nobody criticizes itNeeds 2 to 1 or better, met.
- Recommended in 5 of 13 monthsNeeds 4 or more, met.
The same three rules apply to every product, and the badge can’t be bought. How the badge works
What people say about it
The reasons people give, with the number of comments that give each one. Open a reason to read what they said.
Why people recommend it
Each mark is one comment
Catches undefined behavior at runtime
“Under UBSan the program aborts with the runtime error, so the undefined behavior is caught rather than hidden.”
Comment from 17 Feb 2026 in “What every compiler writer should know about programmers (Anton Ertl, 2015) [pdf]” “I'd be surprised if some combination of ASAN and UBSAN wouldn't catch this and similar dangling references”
Comment from 30 Nov 2025 in “Hardening the C++ Standard Library at scale” “you should catch most trivial cases with e.g. ubsan”
Comment from 20 May 2026 in “Everything in C is undefined behavior” Clear error messages
“Under UBSan the program aborts with the runtime error, so the undefined behavior is caught rather than hidden.”
Comment from 17 Feb 2026 in “What every compiler writer should know about programmers (Anton Ertl, 2015) [pdf]” “It prints a nice error message about the exact issue as the author has shown.”
Comment from 8 Feb 2026 in “The Little Bool of Doom” Used in routine testing
“build and test with sanitizers (ASAN, UBSAN, TSAN) when not measuring performance”
Comment from 10 Oct 2026 in “C for Rust programmers” “a mandatory test pass running with UBSan/ASan/Valgrind”
Comment from 22 Oct 2026 in “Rust Style Guide”
Other sanitizers people recommend
The four most recommended other sanitizers, with the same counts for each, so you can compare like for like. The tick on each bar marks the 2 to 1 line the badge needs.
| Product | Recommend | Criticize | Approval | Months | Owned | Badge |
|---|---|---|---|---|---|---|
| Valgrind | 29 | 8 | 78% | 13 | — | Approved |
| Miri | 26 | 3 | 90% | 12 | — | Approved |
| AddressSanitizer | 21 | 4 | 84% | 7 | — | Approved |
| UndefinedBehaviorSanitizerThis page | 12 | 0 | 100% | 5 | — | Approved |
| Go race detector | 5 | 1 | 83% | 4 | — | — |
What people said
11 of the 12 comments that mention it, newest first. Each links to the original comment.
“a mandatory test pass running with UBSan/ASan/Valgrind”
“UBSAN is also pragmatic enough to focus on the 'important' UB, and ignore the 'irrelevant' types of UB.”
“build and test with sanitizers (ASAN, UBSAN, TSAN) when not measuring performance”
“You can run your code in ASAN in UBSAN nowadays”
“you still need to use ubsan (ie - fsanitize=undefined)”
“you should catch most trivial cases with e.g. ubsan”
“Under UBSan the program aborts with the runtime error, so the undefined behavior is caught rather than hidden.”
“already have several years of production experience, in a mature ecosystem”
“It prints a nice error message about the exact issue as the author has shown.”
“clang-tidy, ASAN, UBSAN, LSAN, MSAN, and TSAN are AMAZING”
“I'd be surprised if some combination of ASAN and UBSAN wouldn't catch this and similar dangling references”
Counts come from 1,795,640 Hacker News comments, November 2025 to November 2026. How we count. Report a mistake.