Re: [PATCH] ubsan: disable UBSAN_DIV_ZERO for clang

From: Linus Torvalds
Date: Thu Jul 14 2022 - 17:25:09 EST


On Thu, Jul 14, 2022 at 1:56 PM Nick Desaulniers
<ndesaulniers@xxxxxxxxxx> wrote:
>
> Linus,
> I still think we should add explicit checks to gaurd against divide by
> zero.

I mean, that's what UBSAN_DIV_ZERO is supposed to do.

The fact that clang then messes it up, and turns "I found undefined
behavior" into "I just crashed the machine" is why it needs to be
disabled.

Please conmvince clang people to fix the sanitizer.

san·i·tize
/ˈsanəˌtīz/
verb
make clean and hygienic; disinfect.

note how "sanitize" is meant to clean things of undefined behavior.

The way you do that is by warning, and giving it defined behavior. It
really is that simple.

Clang seems to warn and then just turn it into ANOTHER - and much
worse - undefined behavior.

In other words, clang doesn't "sanitize" anything at all. It just
moves the mess around and makes it worse.

Linus