-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Win32 multithread dispatching bugs. #265
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this, it's very much appreciated.
FYI: since the patch forced using dispatch table on Win32 the compiler will complain about unused
(See CI log in https://github.com/anholt/libepoxy/runs/4226313433?check_suite_focus=true). |
@ebassi Could you support him further with his question, so this can be merged eventually? |
This pull request resolved some issues I was seeing around the dispatch returning null for function pointers when accessed from different threads |
- Resolve multithreading issues - Enable building as a static library Ref: anholt/libepoxy#265
- Resolve multithreading issues - Enable building as a static library Unfortunately, using it as a static library causes linking errors, so we're keeping the line that forces it to be a dynamic library on Windows. Ref: anholt/libepoxy#265
- Resolve multithreading issues - Enable building as a static library Unfortunately, using it as a static library causes linking errors, so we're keeping the line that forces it to be a dynamic library on Windows. Ref: anholt/libepoxy#265
Is there any progress on this matter ? I am too seeing crashes with Windows builds (no issue on Linux) when trying to create and switch to shared GL contexts, with a Second Life third party viewer I am trying to migrate to libepoxy... EDIT: I applied the "threaded.patch" from dpogue/Plasma@16149d7 and it indeed seems to solve the crashes I was seeing with libepoxy under Windows (more testing will be needed, but so far, so good). |
One way to avoid compiler warnings would be to mark everything with |
Since I'm not a Windows expert or developer, I'd like to get a second pair of eyes; switching to thread-local storage using compiler annotations instead of run time API is a bit iffy; I don't want to regress the shared library use case on Windows just to fix the static build case. I honestly think that static builds of C library in 2022 are a mistake more often than not, anyway. I care about static builds insofar as they don't require weird contortions. |
As a follow up to my previous comment, I must point out that while the use of multiple shared GL contexts do not crash any more libepoxy with that patch, I am faced with a weird issue, where the viewer process never exits on WinMain() return ! |
Not yet completely tested but there is a crash on Windows and it should be solved by this patch. Based on: anholt/libepoxy#200 anholt/libepoxy#265
Using
__thread
(and__declspec(thread)
on MSVC) to replace dirty DllMain hack and thus allowing static build (-Ddefault_library=static
). (Possibly solving #200 issue.)Also fixed race condition in dispatch table logic. Now on Win32 it will always use dispatch table. (#199 minimal reproducing example passed.)