llvm-project
c21cd52f - Fix a crash when a stop hook deletes itself in its callback. (#160416)

Commit
175 days ago
Fix a crash when a stop hook deletes itself in its callback. (#160416) We're iterating over the stop hooks so if one of them changes the stop hook list by deleting itself or another stop hook, that invalidates our iterator. I chose to fix this by making a copy of the stop hook list and iterating over that. That's a cheap operation since this is just an array of shared pointers. But more importantly doing it this way means that if on a stop where one stop hook deletes another, the deleted hook will always get a chance to run. If you iterated over the list itself, then whether that to be deleted hook gets to run would be dependent on whether it was before or after the deleting stop hook, which would be confusing.
Author
Parents
Loading