esdl2 icon indicating copy to clipboard operation
esdl2 copied to clipboard

OSX fix joining main thread with calling thread when exiting

Open brainstormi opened this issue 10 years ago • 3 comments

Current commit fixes a segfault when terminating the app in OSX. Continue to be issues with dtor_Texture that generates a different segfault in current demos, so to be able to replicate the segfault fixed by this commit, limit the code to create a window and exit. On OSX we have to use erl_drv_steal_main_thread, a not documented function to run SDL2 in main thread. In the same way, to join it again with the calling thread when exiting, we have to invoke erl_drv_stolen_main_thread_join instead of enif_thread_join like in Windows/Linux.

brainstormi avatar Dec 21 '15 23:12 brainstormi

I totally missed that. Nice find. Will see if I can try it tomorrow.

essen avatar Dec 21 '15 23:12 essen

I don't think I will have time today. I will get back to you. Thanks!

essen avatar Dec 22 '15 12:12 essen

Added a new PR #12 that should fix all the remaing seg faults in OSX/Windows environments, discussed in issue #2

brainstormi avatar Dec 22 '15 20:12 brainstormi