Skip to content

Add a new target for AddressSanitizer as extra credit #275

Open

Description

@arcuru

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.

Activity

  1. KevinWMatthews commented on Apr 20, 2019

    @KevinWMatthews
    Contributor

    Awesome; good idea.
    Might be worth adding the undefined behavior sanitizer, too.

  2. arcuru commented on Apr 20, 2019

    @arcuru
    ContributorAuthor

    True, though I'm not entirely sure if all of the UBSan checks are valid. Worth looking into though :)

  3. KevinWMatthews commented on Apr 21, 2019

    @KevinWMatthews
    Contributor

    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.

  4. KevinWMatthews commented on Apr 26, 2019

    @KevinWMatthews
    Contributor

    Started this but want to run a few more tests before opening a PR.

  5. arcuru commented on Apr 27, 2019

    @arcuru
    ContributorAuthor

    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

  6. KevinWMatthews commented on May 6, 2019

    @KevinWMatthews
    Contributor

    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.

  7. arcuru commented on May 8, 2019

    @arcuru
    ContributorAuthor
  8. KevinWMatthews commented on Jun 18, 2019

    @KevinWMatthews
    Contributor

    @KevinWMatthews note to self...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions