Commit eb66991
committed
Fixed the race condition in NamedThread
Before this fix, `NamedThread::getCurrentThreadName()` might be called
from the new thread (that already started executing) before the
assignment to `thread_` in the `NamedThread` constructor had taken
place. Then the query to the thread id (`nt->thread_.get_id()`) on such
a thread did not return the correct id, and the end result was that a
new (numbered) thread name was synthesized for that thread. From that
point onward, concurrency orchestration via `log_debug()` (which relies
on correct thread names) broke, typically resulting in a deadlock.
This fix slightly reduces the generality of the `NamedThread` constructor
(support for arguments to the callable has been dropped) since it is not
currently needed (and even if it was needed, it could be circumvented
with an extra lambda expression).1 parent fe520a3 commit eb66991
2 files changed
+14
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | | - | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
42 | 49 | | |
43 | 50 | | |
44 | 51 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| 63 | + | |
| 64 | + | |
56 | 65 | | |
57 | 66 | | |
58 | 67 | | |
| |||
0 commit comments