Skip to content
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

mltonlib opengl segfaults with mlton master #127

Closed
ratmice opened this issue Nov 9, 2015 · 2 comments
Closed

mltonlib opengl segfaults with mlton master #127

ratmice opened this issue Nov 9, 2015 · 2 comments

Comments

@ratmice
Copy link

ratmice commented Nov 9, 2015

I was trying out the opengl libraries in mltonlib/org/mlton/mike/opengl/unstable
but most executables segfault
under current master 22f61a4

The executables run fine with the MLton 20130715 release,
so it seemed like it might be a compiler regression...
I could bisect it if that would help & its not already something known

otherwise if it is actually a problem with mltonlib
let me know and i'll post it in the appropriate place

(gdb) bt
#0 returnAddressToFrameIndex (ra=16)

at /home/ratmice/git/mlton/install/usr/lib/mlton/include/amd64-main.h:35

#1 0x000000000042040f in GC_switchToThread ()
#2 0x00000000004022c3 in MLton_callFromC () at hello.1.c:702
#3 0x000000000040286d in glutDisplayFuncArgument () at hello.1.c:220
#4 0x00007ffff7d9e114 in fghcbDisplayWindow () from /lib64/libglut.so.3
#5 0x00007ffff7da1a39 in fgEnumWindows () from /lib64/libglut.so.3
#6 0x00007ffff7d9e72d in glutMainLoopEvent () from /lib64/libglut.so.3
#7 0x00007ffff7d9ef20 in glutMainLoop () from /lib64/libglut.so.3
#8 0x0000000000407867 in L_176 ()
#9 0x0000000000000001 in ?? ()
#10 0x0000000000402140 in fwrite@plt ()
#11 0x0000000000000000 in ?? ()

@MatthewFluet
Copy link
Member

Almost certainly due to the new _import attribute of pure, impure, and reentrant. In particular, any _import-ed function that directly or indirectly calls an _export-ed function needs to be given the reentrant attribute (which makes sure that the calling ML context is properly suspended when control re-enters ML via the _export-ed function).

We've updated the foreign function interface to make the common case a tiny bit faster --- calling a C function that has no interaction with the ML runtime system. But, a consequence is that we need a little more work for the uncommon case, like callback functions that have an implicit interaction with the ML runtime system.

@ratmice
Copy link
Author

ratmice commented Nov 9, 2015

Thanks Matthew, adding reentrant to the callbacks has fixed it, will send a patch for mltonlibs once i'm sure i haven't missed or overdone anything

@ratmice ratmice closed this as completed Nov 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants