Bug 56682 - -fsanitize documentation
Summary: -fsanitize documentation
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2013-03-21 17:01 UTC by Török Edwin
Modified: 2021-12-19 16:26 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Török Edwin 2013-03-21 17:01:56 UTC
Please update the -fsanitize=address and -fsanitize=thread documentation to specify what additional flags are required.

From my tests:

-fsanitize=thread requires -fPIC for compilation and -pie or -shared for linking.
-fsanitize=address doesn't require any special flags
They both need -g for meaningful output (i.e. if you want to run asan_symbolize on it), and I've seen asan's wiki recommend -fno-omit-frame-pointer too.

If you have an older binutils then -gdwarf-3 is required too, otherwise asan_symbolize (which invokes addr2line) can't resolve the symbol addresses
to sourcefile:linenumber locations.
Comment 1 Andrew Pinski 2013-04-18 01:58:03 UTC
>-fsanitize=thread 

I think it requires -fPIE but really it should not.
Comment 2 sandra 2018-11-26 01:51:44 UTC
This issue is 5+ years old and I think there have been a lot of improvements to the sanitizers meanwhile.  Can the maintainers please comment on what additional options are currently required/recommended?
Comment 3 Martin Liška 2018-11-26 10:31:16 UTC
I really believe there's no need for any extra options on top of -sanitize={address,thread} right now.

The only recommendation would be about the -g option in order to have nice backtraces and variable locations.
Comment 4 sandra 2018-12-05 02:39:04 UTC
Is -g also recommended for the other -fsanitize= options?
Comment 5 Jakub Jelinek 2018-12-05 08:16:13 UTC
Maybe for leak, not sure about that.  For UBSan I think it isn't needed.