-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd: add support for building with address and undefined behavior sanitizers #15059
Conversation
Tue Feb 18 12:09:09 UTC 2025 Spread tests skipped |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #15059 +/- ##
==========================================
+ Coverage 78.07% 78.13% +0.06%
==========================================
Files 1182 1172 -10
Lines 157743 157622 -121
==========================================
+ Hits 123154 123156 +2
+ Misses 26943 26823 -120
+ Partials 7646 7643 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
60354fc
to
d5010ec
Compare
d5010ec
to
a1b04d7
Compare
@@ -319,6 +319,20 @@ AS_IF([test "x$with_unit_tests" = "xyes"], [ | |||
AX_APPEND_COMPILE_FLAGS([-Werror], [CHECK_CFLAGS]) | |||
]) | |||
|
|||
AC_ARG_ENABLE([sanitize], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is only using asan at the moment, would it be better to just call it asan
rather than sanitize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I think perhaps a better option name should be chosen that is more self-explanatory than just sanitize
(plus I expect woke
etc will complain about the use of the term sanitize
as well)
Do you think it makes sense to add ubsan too, even if for unit tests only? |
Sure, the more the merrier particularly if its just the unit tests. |
06d8368
to
12c286f
Compare
12c286f
to
1b967cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good so far. I don't have any high-level comments.
endif | ||
|
||
## | ||
## snap-gdb-shim | ||
## | ||
|
||
if !ENABLE_SANITIZE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you do not add SANITIZE_*
to snap_gdb_shim_snap_gdb_shim_*
. So that would still build, right? Is it just to disable what we are not testing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is so, we should maybe document in the AS_HELP_STRING of --enable-sanitize that it gives a partial build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of both. We don't test it and it won't build. Even with -static-libasan dlopen() is retained for some reason. I guess it just makes libasan parts to be linked statically, but still relies on hijacking libc's malloc dynamically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tweaked the help message.
Add support for building C code with address sanitizer (-fsanitize=address). Signed-off-by: Maciej Borzecki <[email protected]>
Signed-off-by: Maciej Borzecki <[email protected]>
Signed-off-by: Maciej Borzecki <[email protected]>
Signed-off-by: Maciej Borzecki <[email protected]>
Signed-off-by: Maciej Borzecki <[email protected]>
Signed-off-by: Maciej Borzecki <[email protected]>
1b967cc
to
76dfa04
Compare
The branch builds on #15045 and adds support for building with asan and ubsan. This is only useful for testing local installation or running unit tests, as otherwise we'd have to ship libasan/libubsan in the snapd snap to make it universally useful in all scenarios.
Note, some binaries which are linked statically,
snap-gdb*-shim
specifically, had to be skipped, since libasan relies on dlopen().