fix a memory leak, add asan / ubsan support to the cmake configuration#117
Merged
Conversation
…port to the cmake build, and fix a memory leak in `DistributedGeneratorTest`
pelesh
approved these changes
May 30, 2025
pelesh
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for addressing this. I made some optional suggestions.
Comment on lines
+40
to
+55
| # Enable the address sanitizer | ||
| option(GRIDKIT_ENABLE_ASAN "Enable the address sanitizer" OFF) | ||
|
|
||
| if(GRIDKIT_ENABLE_ASAN) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") | ||
| endif() | ||
|
|
||
| # Enable the undefined behavior sanitizer | ||
| option(GRIDKIT_ENABLE_UBSAN "Enable the undefined behavior sanitizer" OFF) | ||
|
|
||
| if(GRIDKIT_ENABLE_UBSAN) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") | ||
| endif() | ||
|
|
Collaborator
There was a problem hiding this comment.
Consider making these flags part of an interface target, then link that target to GridKit libraries.
When we are at it, we could add a "developer mode" compiler flags that include -Wall -Wextra -Wconversion -pedantic.
Collaborator
Author
There was a problem hiding this comment.
users may want to enable address sanitizer or ubsan independent of the target, so i don't think it's worthwhile to do that. however, i have added those compile flags you suggested to the default list of compile flags and fixed all warnings resulting from them in the current tree
…nch to update the pull request
…hat it builds cleanly
WiktoriaZielinskaORNL
pushed a commit
that referenced
this pull request
Jul 23, 2025
#117) * add `.editorconfig`, add undefined behavior and address sanitizer support to the cmake build, and fix a memory leak in `DistributedGeneratorTest` * swap the heap allocated `DistributedGenerator` for one on the stack * add warnings by default and fix warnings resulting from our code so that it builds cleanly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
as the title says