[llvm] Avoid a race condition in opt-viewer/optrecord (PR #131214)
Miro HronĨok via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 20 07:56:29 PDT 2025
================
@@ -64,17 +64,19 @@ class Remark(yaml.YAMLObject):
default_demangler = "c++filt -n"
demangler_proc = None
+ demangler_lock = Lock()
@classmethod
def set_demangler(cls, demangler):
cls.demangler_proc = subprocess.Popen(
demangler.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
- cls.demangler_lock = Lock()
@classmethod
def demangle(cls, name):
with cls.demangler_lock:
+ if not cls.demangler_proc:
----------------
hroncok wrote:
When it's outside of the lock, two workers could attempt to create the process.
1. worker A sees demangler_proc is None
2. worker B sees demangler_proc is None
3. worked A assigns a new process to demangler_proc
4. worker B assigns a new process to demangler_proc
https://github.com/llvm/llvm-project/pull/131214
More information about the llvm-commits
mailing list