Match PETSc object leaks on the syntax tree, not on source text - #249
Merged
Conversation
audit_petsc_file paired object creations with destroy calls by running seven near-identical regexes over each source line. That approach had four defects, all of which the fixture in test/fixtures/leaky.jl now covers: - each regex block ended in `continue`, so only one event per line was recorded; `v = VecCreateSeq(...); VecDestroy(petsclib, v)` counted the creation and missed the release - only whole-line comments were skipped, so `# destroy!(dm)` and a destroy mentioned inside a string literal both counted as releases - only bare and PETSc.-qualified `destroy` were recognised, so LibPETSc.VecDestroy read as a leak - DMPlex objects were not tracked at all, and the high-level Mat/Vec factories (MatSeqAIJ, MatSeqDense, VecSeq, ...) were missed because their names carry no Create or Duplicate marker Walking the parsed AST collapses the seven blocks into one traversal over two name sets. Destroy calls now record every plain name in the argument list, since the object is the first argument high-level (destroy!(v)) and the second low-level (VecDestroy(petsclib, v)). audit_petsc_file returns a NamedTuple of created, destroyed, finalized and leaked instead of nothing, so the behaviour can be asserted; pass verbose = false to suppress the printed report. Nothing tested this file before.
Collaborator
|
@filoferra can you check the conflicts? |
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.
audit_petsc_file paired object creations with destroy calls by running seven near-identical regexes over each source line. That approach had four defects, all of which the fixture in test/fixtures/leaky.jl now covers:
continue, so only one event per line was recorded;v = VecCreateSeq(...); VecDestroy(petsclib, v)counted the creation and missed the release# destroy!(dm)and a destroy mentioned inside a string literal both counted as releasesdestroywere recognised, so LibPETSc.VecDestroy read as a leakWalking the parsed AST collapses the seven blocks into one traversal over two name sets. Destroy calls now record every plain name in the argument list, since the object is the first argument high-level (destroy!(v)) and the second low-level (
VecDestroy(petsclib, v)).Note: audit_petsc_file returns a NamedTuple of created, destroyed, finalized and leaked rather than nothing, so the behaviour can be asserted. It still prints the same report; pass
verbose = falseto suppress it. Nothing in the repo consumed the old return value.