Address Sanitizer support in the build system

Bug #1479333 reported by Ambroz Bizjak
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Wishlist
Andrew Johnson

Bug Description

Attached is a patch (for 3.14) which adds support for Address Sanitizer for Linux x86/x86_64 hosts. ASan can be enabled by setting ASAN=YES in the CONFIG_SITE files. Provided that bug 1479330 is fixed, it seems to work fine.

Note, I've also tried to enable Thread Sanitizer but haven't succeeded. Apparently you need to compile all code with -fPIC or -fpie depending on whether it will be an executable or a library (something like that), and I couldn't figure out how to do that. Could be the current build system doesn't have enough information to pick the right flags.

Revision history for this message
Ambroz Bizjak (ambroz-bizjak) wrote :
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

This seems like a reasonable addition.

Changed in epics-base:
importance: Undecided → Critical
importance: Critical → Low
assignee: nobody → Andrew Johnson (anj)
Revision history for this message
Andrew Johnson (anj) wrote :

After fixing bug 1479330 I do see ASAN warnings from epicsExceptionTest where it also causes 2 tests to fail, but this is probably to be expected given what the code there is doing:

tux-vm-rhel7% ./epicsExceptionTest
1..4
==11845== WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
not ok 1 - new char[18446744073709551615] returned (nil)
==11845== WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
ok 2 - new (nothrow) returned (nil)
==11845== WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
not ok 3 - new char[18446744073709551615] returned (nil)
==11845== WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
ok 4 - new (nothrow) returned (nil)

    Results
    =======
       Tests: 4
      Passed: 2 = 50.00%
      Failed: 2 = 50.00%

Revision history for this message
Andrew Johnson (anj) wrote :

Note that for the previous comment I actually built Base using
    make CMD_LDFLAGS=-fsanitize=address CMD_CFLAGS=-fsanitize=address CMD_CXXFLAGS=-fsanitize=address
instead of applying this patch. I'm not sure that we should add options to the CONFIG_SITE files that are intended for developer use and should not be enabled for production builds, so I'm a bit reluctant to make those particular changes.

I can see that we probably should have a collection of settings for developers to use somewhere in Base, which could also include the -fvisibility=hidden flags that I build with. If we do that, this patch is not really necessary since-fsanitize=address could then be added directly to the OP_SYS_CFLAGS and OP_SYS_LDFLAGS make variables instead.

Please discuss...

Revision history for this message
Ambroz Bizjak (ambroz-bizjak) wrote :

Hey,

I'm fine if we don't add anything to CONFIG_SITE. The important change here is in the CONFIG.gnuCommon which just provides support for enabling it. I don't really see an issue for supporting development features in the CONFIG files as long as they're not enabled by default.

I think the ASAN option should be mentioned in the manual though (is this the right place, http://www.aps.anl.gov/epics/base/R3-14/12-docs/AppDevGuide/node5.html#SECTION00570000000000000000).

I've always used the CONFIG_SITE files even for temporary settings changes during development and generally I'm fine doing it that way. But I do agree it would be nice to have a different place to enable it where all the other development features could also be found. Maybe just some fixed file that is sourced every time, and where all settings are commented out by default?

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

For my part I'd like to see these options (ASAN and visibility) appear somewhere in configure/ to make it easier for developers such as myself who haven't memoried them.

Changed in epics-base:
importance: Low → Wishlist
status: New → Triaged
Andrew Johnson (anj)
Changed in epics-base:
milestone: none → 7.0.2
status: Triaged → Fix Committed
Andrew Johnson (anj)
Changed in epics-base:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.