Closed peter-esik closed 2 months ago
Some additional thoughts:
Instruments
), synchronization overhead is barely measurable in this tool, so this change from atomic variables has no performance implications, at all.This is an interesting case that you have found, thanks for sending in this PR. I agree the possibility of a crash is here and this is one easy way to fix it.
ChangeList::Flush
callednotify_all
. After the waiter (in this case, the main thread) is woken up,notify_all
might not have returned just yet. If the main thread proceeded and calledClear
on theChangeList
object in the meantime, the condition variable is deleted whennotify_all
is still executing, causing a crash. This occurs frequently on my machine when running the tool in "branching mode", and there are changelists happening on lots of "uninteresting" branches (in other words: changelists with 0 files to be committed).ChangeList
class is reworked: instead of multiple atomic variables, mutexes, and condition variables, a single condition variable and mutex is used, with a state machine.