[HOpenGL] HOpenGL && --enable-threaded-rts

Sven Panne Sven_Panne@BetaResearch.de
Wed, 26 Feb 2003 10:24:12 +0100


Tim Docker wrote:
> [...] I noted a long thread last year about --enable-threaded-rts and
> HOpenGL not working togther. The thread did not seem to end in a solution.
> The default ebuild of ghc for gentoo has this flag turned on. Might this be
> the cause of my problems? [...]

Yep, exactly. To recapitulate the tragic story: The current OpenGL
context is a thread-local entity, but GHC's runtime system happily
distributes its work load to different OS threads when it has been
built with --enable-threaded-rts, but this is not correct in the
presence of thread-local entities. Note that it isn't an OpenGL/GLX
design flaw, and it is quite possible other libraries around do
similar things.

There is still some discussion about the correct way of handling this
on the FFI list, especially about the semantics of the "safe", "unsafe",
and "threadsafe" modifiers of foreign calls. The GHC in CVS contains a
lot of modifications in this area, but I haven't tried a threaded RTS
recently.

So in a nutshell: Use a non-threaded RTS until the discussion has
settled down and GHC & HOpenGL use whatever has been concluded...

Cheers,
   S.