Skip to content

Conversation

@wecing
Copy link
Contributor

@wecing wecing commented Apr 3, 2024

DefaultTimingManager::clear() uses out to initialize TimerImpl, but the out is nullptr by default. This means if DefaultTimingManager::setOutput() is never called, DefaultTimingManager destructor may generate SIGSEGV.

`DefaultTimingManager::clear()` uses `out` to initialize `TimerImpl`,
but the `out` is `nullptr` by default. This means if
`DefaultTimingManager::setOutput()` is never called, `DefaultTimingManager`
destructor may generate SIGSEGV.
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Apr 3, 2024
@wecing wecing requested a review from Hsiangkai April 3, 2024 16:50
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2024

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Chenguang Wang (wecing)

Changes

DefaultTimingManager::clear() uses out to initialize TimerImpl, but the out is nullptr by default. This means if DefaultTimingManager::setOutput() is never called, DefaultTimingManager destructor may generate SIGSEGV.


Full diff: https://github.com/llvm/llvm-project/pull/87522.diff

1 Files Affected:

  • (modified) mlir/lib/Support/Timing.cpp (+2-1)
diff --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index 1d6796e9d8dc50..ac16eb7d224c9a 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -499,7 +499,8 @@ class DefaultTimingManagerImpl {
 } // namespace mlir
 
 DefaultTimingManager::DefaultTimingManager()
-    : impl(std::make_unique<DefaultTimingManagerImpl>()) {
+    : impl(std::make_unique<DefaultTimingManagerImpl>()),
+      out(std::make_unique<OutputTextStrategy>(llvm::errs())) {
   clear(); // initializes the root timer
 }
 

@wecing wecing merged commit d5ec49f into llvm:main Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:core MLIR Core Infrastructure mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants