Skip to content

clang/ASAN: Improve coverage #573

Closed
Closed

Description

@jesperpedersen

We need to detect which ASAN flags that are available during a Debug build depending on the clang version

Activity

  1. added
    community
    enhancement
    on Apr 4, 2025
  2. bassamadnan commented on Apr 5, 2025

    @bassamadnan
    Collaborator

    can I take this up? I want to work with ASAN abit, I remember encountering issues in pgexporter/pgexporter#178 with the memory bit too so maybe I can add a cmake/Sanitizers.cmake file, which will check clang version and see if flags can be added (check_c_compiler_flag("-fsanitize-recover=address"...) in the version.

  3. bassamadnan commented on Apr 5, 2025

    @bassamadnan
    Collaborator

    are there any specific flags you have in mind?

  4. jesperpedersen commented on Apr 5, 2025

    @jesperpedersen
    MemberAuthor

    @bassamadnan Go for it !

    See src/CMakeLists.txt for the flags we currently have enabled. But, create a list of flags for each clang version, and then do a test if it is available if so enable.

    We don't need a special file for it

  5. jesperpedersen commented on Apr 5, 2025

    @jesperpedersen
    MemberAuthor

    Maybe do a general doc/manual/dev-05-building.md chapter with the ASAN information as a section.

    You can move the building information from the test chapter into it to begin with.

    Move the other chapters "up"

  6. bassamadnan commented on Apr 5, 2025

    @bassamadnan
    Collaborator

    Yes will do! Is it fine if i do this for pgexporter first? Abit in sync with the codebase there and i can test some of the things i've wanted to for a while

  7. jesperpedersen commented on Apr 5, 2025

    @jesperpedersen
    MemberAuthor

    @bassamadnan Sure, just create the issue there

  8. bassamadnan commented on Apr 5, 2025

    @bassamadnan
    Collaborator

    See src/CMakeLists.txt for the flags we currently have enabled.

    Just to be sure, we currently do not have any ASan specific flags right? I am thinking about adding these flags for compiling

    -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize-recover=address
    

    I've been reading up on them

    1. fsanitize-recover=address controls error recovery mode for sanitizers
    2. fsanitize-address-use-after-scope detects variables outside their scope (docs)

    I'll read up on the support for above flags for different clang versions (6 through 20) or just manually run it on docker containers. I think this is all we would need while going into Debug mode? Let me know if something else would be required

  9. jesperpedersen commented on Apr 5, 2025

    @jesperpedersen
    MemberAuthor

    Yes, it is all the -fsantizeXYZ flags I'm talking about, plus other flags that can help us during development and debugging

  10. bassamadnan commented on Apr 6, 2025

    @bassamadnan
    Collaborator

    Im using godbolt. Its the most reliable tool I could find, to test these flags specifically

    -fsanitize=address 
    -fno-omit-frame-pointer 
    -fsanitize-address-use-after-scope 
    -fsanitize-recover=address 
    -Wall 
    -Wextra
    

    These are supported for all clang x86-64 versions above 4. For 3.x.x they give warnings but from 3.4-3.9 they give compilation errors altogether. Should we add checks for clang 3? because otherwise they are the same. Also similliar scenarios arise for x86-64 gcc compilers, where these flags give error (specifically -fsanitize-address-use-after-scope for gcc versions below 7.1) maybe we can add checks for these too for gcc?

    For clang the specific flags which fail in range 3.4-3.9 are -fsanitize-address-use-after-scope -fsanitize-recover. Let me know if it is ok to add these checks and for versions greater than specific versions (4 for clang, 7.1 for gcc) version add all the flags.

  11. jesperpedersen commented on Apr 6, 2025

    @jesperpedersen
    MemberAuthor

    @bassamadnan Yes, that is the idea -- for Debug include as many options as possible for gcc and clang

  12. bassamadnan commented on Apr 6, 2025

    @bassamadnan
    Collaborator

    yup, on it!

  13. added a commit that references this issue on Apr 13, 2025
  14. 2 remaining items

  15. added 14 commits that reference this issue on Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

communityenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions