Assertion in addTimer

Hi,

I’m hitting this assertion in Timer::addTimer:

        // Trying to add a timer that's already here - shouldn't get to this point,
        // so if you get this assertion, let me know!
        jassert (std::none_of (timers.begin(), timers.end(),
                               [t] (TimerCountdown i) { return i.timer == t; }));

This is on macOS 26, and the Thread Sanitizer also complains about a data race in Timer::startTimer(int):

    bool wasStopped = (timerPeriodMs == 0);   <--- Thread Sanitizer complains
    timerPeriodMs = jmax (1, interval);       <--- about these two lines

    if (wasStopped)
        timerThread->addTimer (this);         <--- Crashes here (inside addTimer)
    else
        timerThread->resetTimerCounter (this);

I’ve only seen the assertion trigger when having the Thread Sanitizer running, so maybe it is triggered by using it. Still, it looks like there may be a race condition? If I change timerPeriodMs to an std::atomic, the problem seems to go away.

Can you try updating to the latest develop branch (or at least version 9.0.3). timerPeriodMs is already an atomic. if you’re still seeing any issues there let me know.

Thanks.

Alright, thanks a lot for your answer!

1 Like