This is an archive of the discontinued LLVM Phabricator instance.

Avoid calling ParseCommandLineOptions in BackendUtil if possible
ClosedPublic

Authored by teemperor on Apr 1 2021, 9:16 AM.

Details

Summary

Calling ParseCommandLineOptions should only be called from main as the
CommandLine setup code isn't thread-safe. As BackendUtil is part of the
generic Clang FrontendAction logic, a process which has several threads executing
Clang FrontendActions will randomly crash in the unsafe setup code.

This patch avoids calling the function unless either the debug-pass option or
limit-float-precision option is set. Without these two options set the
ParseCommandLineOptions call doesn't do anything beside parsing
the command line clang which doesn't set any options.

See also D99652 where LLDB received a workaround for this crash.

Diff Detail

Event Timeline

teemperor requested review of this revision.Apr 1 2021, 9:16 AM
teemperor created this revision.
JDevlieghere accepted this revision.Apr 1 2021, 9:18 AM
JDevlieghere added a subscriber: JDevlieghere.

LGTM

This revision is now accepted and ready to land.Apr 1 2021, 9:18 AM
This revision was landed with ongoing or failed builds.Apr 1 2021, 10:41 AM
This revision was automatically updated to reflect the committed changes.