aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorArtemiy Bulavin <artemiyb@graphcore.ai>2025-03-13 10:00:39 -0400
committerGitHub <noreply@github.com>2025-03-13 15:00:39 +0100
commit0aa5ba43a0d11ce8e7f143380ae75fea516b6841 (patch)
treeb5aeae78a4a65766dc869b27a1d0ee2a4be3da26 /flang/lib/Frontend/CompilerInvocation.cpp
parentc26ec7ea2add1e9ca78d7a2c03350447671bfc1b (diff)
downloadllvm-0aa5ba43a0d11ce8e7f143380ae75fea516b6841.zip
llvm-0aa5ba43a0d11ce8e7f143380ae75fea516b6841.tar.gz
llvm-0aa5ba43a0d11ce8e7f143380ae75fea516b6841.tar.bz2
[mlir] Fix DistinctAttributeUniquer deleting attribute storage when crash reproduction is enabled (#128566)
Currently, `DistinctAttr` uses an allocator wrapped in a `ThreadLocalCache` to manage attribute storage allocations. This ensures all allocations are freed when the allocator is destroyed. However, this setup can cause use-after-free errors when `mlir::PassManager` runs its passes on a separate thread as a result of crash reproduction being enabled. Distinct attribute storages are created in the child thread's local storage and freed once the thread joins. Attempting to access these attributes after this can result in segmentation faults, such as during printing or alias analysis. Example: This invocation of `mlir-opt` demonstrates the segfault issue due to distinct attributes being created in a child thread and their storage being freed once the thread joins: ``` mlir-opt --mlir-pass-pipeline-crash-reproducer=. --test-distinct-attrs mlir/test/IR/test-builtin-distinct-attrs.mlir ``` This pull request changes the distinct attribute allocator to use different allocators depending on whether or not threading is enabled and whether or not the pass manager is running its passes in a separate thread. If multithreading is disabled, a non thread-local allocator is used. If threading remains enabled and the pass manager invokes its pass pipelines in a child thread, then a non-thread local but synchronised allocator is used. This ensures that the lifetime of allocated storage persists beyond the lifetime of the child thread. I have added two tests for the `-test-distinct-attrs` pass and the `-enable-debug-info-on-llvm-scope` passes that run them with crash reproduction enabled.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions