Commit 7086b50
committed
Avoid a race condition in opt-viewer/optrecord
See https://bugzilla.redhat.com/2336915
See https://reviews.llvm.org/D41784?id=
See androm3da/optviewer-demo#4 (comment)
Fixes #62403
The race condition happened when the demangler_proc was being set.
The locking mechanism itself happened too late.
This way, the lock always exists (to avoid a race when creating it)
and is always used when *creating* demangler_proc.
I don't have any prior experience with the codebase
and I cannot guarantee the behavior is correct.
It appears to get rid of the race (which I was seeing consistently).
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib64/python3.14/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
~~~~^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optpmap.py", line 25, in _wrapped_func
return func(argument, filter_)
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 293, in _render_file
SourceFileRenderer(source_dir, output_dir, filename, no_highlight).render(remarks)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 216, in render
self.render_source_lines(self.source_stream, line_remarks)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 123, in render_source_lines
self.render_inline_remarks(remark, html_line)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 126, in render_inline_remarks
inlining_context = r.DemangledFunctionName
^^^^^^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optrecord.py", line 153, in DemangledFunctionName
return self.demangle(self.Function)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optrecord.py", line 77, in demangle
with cls.demangler_lock:
^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Passed' has no attribute 'demangler_lock'. Did you mean: 'demangler_proc'?
"""1 parent bbb244c commit 7086b50
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
326 | | - | |
327 | | - | |
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| |||
0 commit comments