Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

work around segfault bug with clang custom passes #18

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

ddcc
Copy link
Contributor

@ddcc ddcc commented Aug 30, 2019

When shutting down LLVM, the custom pass shared library can be prematurely unloaded, resulting in a dangling pointer. As a workaround, instruct the linker to mark the custom pass not to be unloaded at runtime.

References:
https://groups.google.com/forum/#!msg/afl-users/TDLrTu3V_Pw/K4svutarAAAJ
https://stackoverflow.com/questions/47712670/segmentation-fault-in-llvm-pass-when-using-registerstandardpasses
sampsyo/llvm-pass-skeleton#7

Upstream bugs:
https://bugs.llvm.org/show_bug.cgi?id=34573
https://bugs.llvm.org/show_bug.cgi?id=39321
https://bugs.llvm.org/show_bug.cgi?id=36183

When shutting down LLVM, the custom pass shared library can be prematurely unloaded, resulting in a dangling pointer. As a workaround, instruct the linker to mark the custom pass not to be unloaded at runtime.

References:
https://groups.google.com/forum/#!msg/afl-users/TDLrTu3V_Pw/K4svutarAAAJ
https://stackoverflow.com/questions/47712670/segmentation-fault-in-llvm-pass-when-using-registerstandardpasses

Upstream bugs:
https://bugs.llvm.org/show_bug.cgi?id=34573
https://bugs.llvm.org/show_bug.cgi?id=39321
https://bugs.llvm.org/show_bug.cgi?id=36183
@ddcc
Copy link
Contributor Author

ddcc commented Aug 30, 2019

I don't have the time to bisect this, but as of current trunk (see #19), the underlying LLVM bug seems to have been fixed.

@jonathanmetzman
Copy link
Contributor

I'm less familiar with afl-clang-fast since I mostly use trace-pc-guard but this patch seems widely used as a fix, and I've confirmed it allows building the pass with clang-6.0. on Ubuntu 16.04.6 (where it is currently broken).

@jonathanmetzman jonathanmetzman merged commit 6594298 into google:master Aug 30, 2019
@jonathanmetzman
Copy link
Contributor

Thanks for the patch!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants