aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/InitPreprocessor.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2024-07-02 10:08:03 +0200
committerGitHub <noreply@github.com>2024-07-02 10:08:03 +0200
commit01e96c86497ac9670e1168134870beb99cbd4d8f (patch)
tree586bb22615a924563bfa59f755b77fd644baf17f /clang/lib/Frontend/InitPreprocessor.cpp
parent54f040fff301a629f2ed032863408ed119789b0e (diff)
downloadllvm-01e96c86497ac9670e1168134870beb99cbd4d8f.zip
llvm-01e96c86497ac9670e1168134870beb99cbd4d8f.tar.gz
llvm-01e96c86497ac9670e1168134870beb99cbd4d8f.tar.bz2
[lldb] Don't unregister a listener that's being destroyed (#97300)
It's not necessary because the broadcasters hold a weak_ptr (*) to it, and will delete the weak_ptr next time they try to lock it. Doing this prevents recursion in RemoveListener, where the function can end up holding the only shared_ptr to a listener, and its destruction can trigger another call to RemoveListener -- which will mess up the state of the first instance. This is the same bug that we've have fixed in https://reviews.llvm.org/D23406, but it was effectively undone in https://reviews.llvm.org/D157556. With the addition of a primary listener, a fix like D23406 becomes unwieldy (and it has already shown itself to be fragile), which is why this patch attempts a different approach. Like in 2016, I don't know a good way to unit test this bug, since it depends on precise timing, but the thing I like about this approach is that it enables us to change the broadcaster mutex into a non-recursive one. While that doesn't prevent the bug from happening again, it will make it much easier to spot in the future, as the code will hang with a smoking gun (instead of crashing a little while later). I'm going to attempt that in a separate patch to minimize disruption. (*) Technically a broadcaster holds the *primary* listener as a shared_ptr, but that's still ok as it means that listener will not get destroyed until it is explicitly removed.
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions