mozilla / cubeb

Cross platform audio library
ISC License
439 stars 124 forks source link

Null check g_cubeb_log_callback before using #730

Closed padenot closed 1 year ago

padenot commented 1 year ago

When logging asynchrously, there's ample time for the pointer to be nulled.

padenot commented 1 year ago

To address that, we'd either need to ensure async logging is never active when this is changed,

I went this route, and did other things as well. It's a lot bigger, a tad more complex, but I added tests (that pass locally when stress tested (a lot more iterations on a bunch of runs) on aarch64/M1 max and x86_64/Linux).

padenot commented 1 year ago

Matthew, I ended up slightly modifying the test to remove delay(...) calls and use atomics to ensure that callbacks were called, because otherwise the test was super unreliable on the CI here. I think it's better regardless.