Skip to content

Using Unity with Address Sanitizer (ASAN) #820

@stessaris

Description

@stessaris

I'd like to use Unity in combination with Address Sanitizer, the problem is that by default ASAN halts the program as soon that it detects a memory error, so failed assertions in tests like:

  1. allocate some memory
  2. some Unity assertions that might fail
  3. free allocated memory

are never reported as failed assertions because ASAN kicks in and halts the program reporting a memory leak. This is misleading because the cause of the failed assertion is lost.

I know I can instruct ASAN to continue after the error, instead of halting (see FAQs; but it's marked as experimental.

I was wondering whether there is a "correct" way to use ASAN with unity, or it's just a bad idea to combine their use. The ideal would be to be able to specify some cleanup code associated with the (group of) assertions, but I cannot find out how this can be done in Unity at the assertion level.

I'm using Unity and ASAN together to check programming assignments, so it makes sense to check also for memory errors in the unit test, and I'd rather prefer avoiding the duplication of the tests.

Thanks for any suggestion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions