Add a new target for AddressSanitizer as extra credit
One of the things we do in the C track is have a separate compilation target for validating memory accesses, which we do using AddressSanitizer. We should implement a similar check here by adding a new target into each exercise's CMakeLists to run the tests under ASan, and document that to describe it as extra credit for the students in the 'Running the Tests' doc page.
Possibly add a build with MemorySanitizer as well to track uninitialized reads, but ASan is generally more useful.
Awesome; good idea. Might be worth adding the undefined behavior sanitizer, too.
True, though I'm not entirely sure if all of the UBSan checks are valid. Worth looking into though :)
Not all valid? Haven't stumbled across that yet but am super curious to learn what your concerns are. I've been bitten by false positives before; there actually seem to be (?) bugs in older versions of gcc's TSan implementation.
Would you prefer a separate make target or a CMake option? In other contexts I've used options with success, something like -DENABLE_ASAN and -DENABLE_UBSAN. I don't have a strong opinion in this use case. CMake recompiles appropriately if you change an option.
Options might be better if we allow for multiple sanitizers. For example, ASan and UBsan can be enabled independently and/or simultaneously.
Started this but want to run a few more tests before opening a PR.
By 'not valid', I should have said "I don't know much about UBSan, but based on what it does I'd guess it may generate false positives".
Honestly I'm not sure if a separate make target or a CMake option is better, either would work. I'd probably prefer CMake, at least with how ASan works, since it's a configuration option that you'd want to just apply to all the builds your doing.
In the C track we just have a separate make target, but everything is done through the makefile - https://github.com/exercism/c/blob/master/exercises/hello-world/makefile
I see. If UBSan is a configurable option, maybe it isn't so bad to try it? It could be confusing, but one wouldn't be forced into it.
I think the CMake option is the way to go if possible - it matches everything else in the track.
Yea, I think adding these behind a CMake option sounds good. I'm not too concerned about providing that build option, especially since we don't plan to make it mandatory anywhere.
On Mon, May 6, 2019 at 8:33 AM Kevin W Matthews [email protected] wrote:
I see. If UBSan is a configurable option, maybe it isn't so bad to try it? It could be confusing, but one wouldn't be forced into it.
I think the CMake option is the way to go if possible - it matches everything else in the track.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/exercism/cpp/issues/275#issuecomment-489665003, or mute the thread https://github.com/notifications/unsubscribe-auth/AABHHBQPOWWUOVCNUSCHZTLPUBFULANCNFSM4HHKD3RQ .
@KevinWMatthews note to self...