[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gcc and undefined behavior



On 2014-04-28 16:45:56 +0000, Thorsten Glaser wrote:
> Shachar Shemesh <shachar <at> debian.org> writes:
> 
> >     the changes there is a runtime check for undefined behavior. Just
> >     compile with -fsanitize=undefined, and your program will crash with
> >     log if it performs an operation that C/C++ considers to be
> >     undefined.
> 
> This does not help. At all.

For you.

Clang's sanitizer (which was there before GCC's) helped us to find
bugs in MPFR.

> Consider:
> 
> • all possible codepaths
> 
>   ×
> 
> • all possible combinations of input/state data

There's the same problem with test suites. They can't test every
possibility, but they are still useful (for both the developers to
test their software and check for regressions, and for the user due
to possible compiler bugs).

> Plus, crashing in a screensaver is bad :D

The sanitizers should be used only for testing / debugging, or
possibly for critical applications where it may be better to crash
(in a controlled way) than behave erratically with possible system
compromission as a consequence.

In the case of a screensaver, this should only be done for testing /
debugging. If the screensaver crashes, this is probably due to a bug
one may want to fix. So, this is useful.

Perhaps some testers might want to build a full Debian system with
-fsanitize=undefined and see what happens...

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Reply to: