Skip to content

Commit fbfb70a

Browse files
committed
[analyzer] Disable graph-trim-interval by default
Because this hack is responsible for use-after-free errors that can trigger assertion failures, as reported e.g. in the github issue #105512 Disabling this performance optimization can cause severe slowdowns (up to +200% runtime) on a few specific translation units, but its effects are barely significant when they are averaged over a whole project: even on projects that are "severely affected" the slowdowns are <20 seconds. If someone happens to be heavily affected by this performance loss (and doesn't fear the crashes) they can re-enable ExplodedNode reclamation by passing -analyzer-option graph-trim-interval=1000 (the old default) to the analyzer. This commit is a temporary workaround to eliminate the crashes ASAP; in addition to this, we're also working to develop a long-term solution that can hopefully remove 'graph-trim-interval' altogether and replace it with different solutions that guarantee a good runtime without breaking the invariants of the ExplodedGraph. (It would be much easier to reason about the execution paths if we didn't have to think about the case that some nodes can just disappear.)
1 parent 3645c64 commit fbfb70a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,11 @@ ANALYZER_OPTION(
393393

394394
ANALYZER_OPTION(
395395
unsigned, GraphTrimInterval, "graph-trim-interval",
396-
"How often nodes in the ExplodedGraph should be recycled to save memory. "
397-
"To disable node reclamation, set the option to 0.",
398-
1000)
396+
"[DEPRECATED] When set to a number N > 0, this enables reclamation of "
397+
"'unimportant' nodes in the ExplodedGraph once per N node creation steps. "
398+
"This reduces the memory usage, but can cause use-after-free errors or "
399+
"crashes, so will be phased out.",
400+
0)
399401

400402
ANALYZER_OPTION(
401403
unsigned, MinCFGSizeTreatFunctionsAsLarge,

clang/test/Analysis/analyzer-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
// CHECK-NEXT: experimental-enable-naive-ctu-analysis = false
8585
// CHECK-NEXT: exploration_strategy = unexplored_first_queue
8686
// CHECK-NEXT: faux-bodies = true
87-
// CHECK-NEXT: graph-trim-interval = 1000
87+
// CHECK-NEXT: graph-trim-interval = 0
8888
// CHECK-NEXT: ignore-bison-generated-files = true
8989
// CHECK-NEXT: ignore-flex-generated-files = true
9090
// CHECK-NEXT: inline-lambdas = true

0 commit comments

Comments
 (0)