Closed konnorandrews closed 1 year ago
Thanks for the report. It should be noted that on some OSes (such as macOS) creating windows on anything but the main thread is not supported (this is enforced by the macOS APIs and nothing minifb can do anything about)
As minifb aims to behave the same across all platforms I think it would be better simply disallow window creation on anything, but the main thread.
I decided to implement your suggestion. Thanks! It's included in version 0.24
that has been published
In the course of helping @Egggg with a
SIGSEGV: invalid memory reference
, I generated the following backtrace with llvm's address sanitizer.After some investigation I found that
minifb
does not appear to runXInitThreads
when it initializes it's X11 instance. Because of this, when used by multiple threadsminifb
calls into X11 code without proper thread synchronization.The following is a minimal reproducible example. The error should be seen if run with
RUSTFLAGS=-Zsanitizer=address cargo +nightly run
.Adding the following code before calling
Window::new
results in address sanitizer not reporting any memory violations, and the code working as expected