-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
seg fault after bullet sample completes #2
Comments
Yeah then it's definitely to do with GC order. I guess Linux doesn't care about it but OSX does. |
I've been looking into this. On Linux I get the renderer destroyed before the window, so no problem. Can you add a printf in both dtor functions of c_src/sdl_renderer.c and c_src/sdl_window.c and tell me in what order they are called? If this is the actual issue then I have a fix in mind. Otherwise, heh, I'll need an OSX to test. |
I believe this one should be fixed in the newest commit. |
unfortunately, the issue persists on osx 10.9 |
I have an OSX around in a VM now, I will try when I can access it. |
Well I fail to even compile it. I will get back to you. |
I can reproduce. I will get you something during the day. |
My problem might be because SMP was not enabled (trying to add a second core to the VM, but OSX doesn't seem to like that...). Do you have SMP enabled? |
OK the SMP issue I could fix by adding -smp enable. And now I finally could observe the issue. I'll work on a fix when possible. |
Yes, smp is enabled when the issue raised... Thanks for your support. I
|
Feel free to open a new ticket, tickets are fine for discussions. :-) |
Issue persist with esdl2 master brach in OSX... Segfault when demo ends: |
Yep I confirm this both on Windows and OSX. Fine on Linux. |
I'm just trying to get some insights about this issue... but trying to setup a dummy debugging environment for erlang+nifs in OSX/Windows is causing me more than a headache. I could make some progress in OSX side, it seems a bit easier than windows to setup a enabled debug emulator, following the instructions in: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread Launching it with standard emulator, crash at the end, as always... but seems to be associated to a missing texture ?¿???¿ ... this is only my assumption looking at the stack because I can't trace anything :( Thread 15 Crashed:: 2_scheduler Seeing your last try to solve GC order between Renderer and Window using enif_keep_resource, enif_release_resource and the dependency macros for resources you integrated looks good... could it be the same but this time between Renderer and Texture GC order?... I'm only thinking out loud shooting at anything that moves... |
This would be my guess, yes. Especially considering the second stack trace you just gave. I don't really know how to get proper debug info other than going through the docs, looks like you are already more equipped than me. Last time I believe it was half guess half printf debugging. |
After some more tests, I'm more confused than before... Not sure anymore that it's related to a GC order issue, probably more to some kind of timing/synchronization issue. |
A few tests you can do: Try creating a window and do nothing else (no loop, no call, just the process exiting). Do the same with different window options. Do the same with a renderer. Do the same with texture. Add a loop. Etc. |
In windows os, just creating a simple window makes it hangs indefinitely when trying to invoke dtor_Window on exit... it doesn't matter if the dll is cross-compiled with Msys2 or generated with VS2015. |
Do you have a stacktrace of the crash on Windows? Is it any different from OSX? |
Unfortunately I'm not able to generate the segfault anymore... In the beginning the usual behaviour was that launching it (hello_sdl demo) after a clean compilation generated this same freeze behaviour trying to close the window; following execution tries generated the segfault issue. |
Excuse me, my fault, I know what is happening with the freeze behaviour... I substituted the SDL2.dll by the dev one in order to debug the issue; this has been causing the freeze issue. With the SDL2.dll release version it generates again the segfault in windows. |
I was too quick... the freeze behaviour persists when exiting... It seems that the segfault could be dtor_texture when it's raised... but now, most of the times this doesn't happens and only freeze calling dtor_window... sorry no stacktrace, just erlang vm and window sits there forever until you kill the window. As pointed, same behaviour if you create only a windows and pull sdl events in a loop. |
Ok, I have one last theory about what could be happening here... SDL_Destroy## functions are not thread safe calls and SDL multi-threading support varies between OS implementations, taking as dumb rule SDL is not thread safe, full period. It seems they are executed out of the main thread in esdl2 nif, so this would explain why different dtor_## functions shows different behaviors on different OS (OSX dtor_Texture seg faults, meanwhile dtor_window in Windows freezes). Also this would explain the random behavior in Windows, alternating freezes with seg faults?. |
Makes sense. |
That's why we have a thread in the first place. |
I see the same crash, but also it will crash if I click away and the window loses focus. |
The text was updated successfully, but these errors were encountered: