Skip to content

Conversation

@hokein
Copy link
Collaborator

@hokein hokein commented Nov 8, 2024

This fixes dangling ErrorHandler references (here is an example).

llvm::function_ref doesn't own the callable, and it is not safe to store a function_ref (the PlainPrinterBase stores a llvm::function_ref which can easily lead to dangling references).

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2024

@llvm/pr-subscribers-debuginfo

Author: Haojian Wu (hokein)

Changes

This fixes dangling ErrorHandler references (here is an example).

llvm::function_ref doesn't own the callable, and it is not safe to store a function_ref (the PlainPrinterBase stores a llvm::function_ref which can easily lead to dangling references).


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

1 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h (+1-1)
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
index 72ffdd29f1b72d..828875f1bb0ede 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -65,7 +65,7 @@ struct PrinterConfig {
   int SourceContextLines;
 };
 
-using ErrorHandler = function_ref<void(const ErrorInfoBase &, StringRef)>;
+using ErrorHandler = std::function<void(const ErrorInfoBase &, StringRef)>;
 
 class PlainPrinterBase : public DIPrinter {
 protected:

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2024

@llvm/pr-subscribers-llvm-binary-utilities

Author: Haojian Wu (hokein)

Changes

This fixes dangling ErrorHandler references (here is an example).

llvm::function_ref doesn't own the callable, and it is not safe to store a function_ref (the PlainPrinterBase stores a llvm::function_ref which can easily lead to dangling references).


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

1 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h (+1-1)
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
index 72ffdd29f1b72d..828875f1bb0ede 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -65,7 +65,7 @@ struct PrinterConfig {
   int SourceContextLines;
 };
 
-using ErrorHandler = function_ref<void(const ErrorInfoBase &, StringRef)>;
+using ErrorHandler = std::function<void(const ErrorInfoBase &, StringRef)>;
 
 class PlainPrinterBase : public DIPrinter {
 protected:

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hokein hokein merged commit 9aea667 into llvm:main Nov 8, 2024
11 checks passed
@hokein hokein deleted the function-ref-debug-info branch November 8, 2024 15:01
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
…function. (llvm#115477)

This fixes dangling `ErrorHandler` references
([here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp#L48-L53)
is an example).

`llvm::function_ref` doesn't own the callable, and it is not safe to
store a function_ref (the `PlainPrinterBase` stores a
`llvm::function_ref` which can easily lead to dangling references).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants