ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.05k stars 395 forks source link

Freeze/UB in multicast_observer #460

Open martinfinke opened 6 years ago

martinfinke commented 6 years ago

In my application, RxCpp freezes in this line. It seems to depend on timing, and I think it's more likely to happen when the run loop (where it's being called) is running at longer intervals (more "slowly"). I'm using macOS 10.13.6.

When it freezes, there is only the main thread "active" (all other threads are sleeping and not calling RxCpp).

If I change state_type::lock to a std::recursive_mutex (and change the unique_locks to fit), it fixes the problem. So it seems that the thread already owns the mutex, in which case the behavior with std::mutex is undefined.

Attached is a partial call stack, starting from my on_next call.

Call Stack.txt

Is it okay to replace it by std::recursive_mutex, or does that create other problems?

kirkshoop commented 6 years ago

Hi!

Is there any way to get the full call stack for the stuck thread?

I have been poring over the code and I see one potential scenario that might cause this, but the part of the stack that I see, does not match this scenario.

Thanks!