Skip to content
Aborted

Changes

Summary

  1. Sanitizer(UBSAN): really enable UBSAN (commit: 1cb3666) (details)
  2. Sanitizers(UBSAN): fix linker warning (commit: 0a88f1e) (details)
  3. Sanitizers: move flag definitions (commit: c3b3464) (details)
  4. Sanitizers: add a test that ASAN/UBSAN work (commit: 52d93a5) (details)
  5. Sanitizer(UBSAN): switch to printing instead of trap (commit: 9f7aad8) (details)
  6. Sanitizers: add -g flag (commit: 9addfad) (details)
  7. Sanitizers: future proof by using -Og instead of -o1 (commit: 7c08154) (details)
Commit 1cb36665a25f7427a198a51bfc48927a52a4d5a8 by edwin.torok
Sanitizer(UBSAN): really enable UBSAN

The clang-14 docs are not clear about this, but the latest docs say:
> -fsanitize-trap= and -fsanitize-recover= are a no-op in the absence of a -fsanitize= option. There is no unused command line option warning.

Avoid this trap and specify `-fsanitize=$ubsan` too.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 1cb3666)
The file was modifiedtools/ci/inria/sanitizers/script
Commit 0a88f1e3d0f520dc2f83125bb83add79f53d2691 by edwin.torok
Sanitizers(UBSAN): fix linker warning

Apparently >-O0 needs to be supplied when linking too:
```
clang: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled: -fsanitize=bool,builtin,bounds,enum,nonnull-attribute,nullability,object-size,pointer-overflow,returns-nonnull-attribute,shift-exponent,unreachable [-Winvalid-command-line-argument]
```

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 0a88f1e)
The file was modifiedtools/ci/inria/sanitizers/script
Commit c3b34648ea3a058462c74e550a3b7822a872a497 by edwin.torok
Sanitizers: move flag definitions

Move compiler flag definitions to shell variables.
This will enable testing them.

No functional change yet.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: c3b3464)
The file was modifiedtools/ci/inria/sanitizers/script
Commit 52d93a5b8446671eac8c834ea0f45219521a5937 by edwin.torok
Sanitizers: add a test that ASAN/UBSAN work

Compile 2 small test programs, and check expected output.
The test programs are deleted on success.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 52d93a5)
The file was modifiedtools/ci/inria/sanitizers/script
Commit 9f7aad844b94bf247c7a906c683d942d3ca0d5ad by edwin.torok
Sanitizer(UBSAN): switch to printing instead of trap

Still stop on first error, but instead of dumping core print a message,
and stacktrace, like ASAN.

This may be more convenient when used in a CI than a coredump.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 9f7aad8)
The file was modifiedtools/ci/inria/sanitizers/script
Commit 9addfada6693b6dcb30c5139eb4dddc41983c8d7 by edwin.torok
Sanitizers: add -g flag

For better stacktraces.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 9addfad)
The file was modifiedtools/ci/inria/sanitizers/script
Commit 7c081549379671b23fcd1089036f87c59a043505 by edwin.torok
Sanitizers: future proof by using -Og instead of -o1

This is currently equivalent to -O1 on clang, but may improve debuggability in the future compared to -O1.

GCC already disables certain optimizations at -Og, and recommends it when using the sanitizers:
```
To get more accurate stack traces, it is possible to use options such as -O0, -O1, or -Og (which, for instance, prevent  most  function  inlining)
```

(there are also other flag recommendations, but I think they are only relevant if you want to use -O2 or higher,
they wouldn't be active at -O1/-Og)

Also don't use -O0. Even for pure debugging, the manual recommends -Og:
```
It is a better choice than -O0 for producing debuggable code because some compiler passes that collect debug information are disabled at -O0
```

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
(commit: 7c08154)
The file was modifiedtools/ci/inria/sanitizers/script