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

Fix freeze when using threaded RTS on windows #91

Merged
merged 1 commit into from Feb 24, 2015

Conversation

wrvn
Copy link
Contributor

@wrvn wrvn commented Feb 14, 2015

There is a bug on Windows with recent versions of gtk (tested with 2.24.24, 2.24.25 and 3.14.8) that causes whole application to freeze when moving window. Also its mentioned here #33.

The underlying issue is somewhere deep in gtk callback hell where gdk_threads_enter() is getting called twice resulting in deadlock.

The only reason this issue is not observed in non threaded programs is becaue gdk_threads_init() is only called when compiling with -threaded.

This workaround simply replaces default gdk locking functions that use nonrecursive mutex with those that use recursive one.

Also here is simple c program that demonstrates this issue http://pastebin.com/5Gz2KdmA.

There is a bug on Windows with recent versions of gtk (tested with 2.24.24, 2.24.25 and 3.14.8) that causes whole application to freeze when moving window. Also its mentioned here gtk2hs#33.
The underlying issue is somewhere deep in gtk callback hell where gdk_threads_enter() is getting called twice resulting in deadlock.
The only reason this issue is not observed in non threaded programs is becaue gdk_threads_init() is only called when compiling with -threaded.
This workaround simply replaces default gdk locking functions that use nonrecursive mutex with those that use recursive.
Also here is simple c program that demonstrates this issue http://pastebin.com/5Gz2KdmA.
@emmanueltouzery
Copy link
Contributor

I mentioned in issue #33 having the problem. I now rebuilt my program for windows.
First I rebuilt it with the gtk3 package without the fix and sure enough, freeze when I attempt the resize the window.
Then I applied the fix. No more freeze! I then did a basic testing of the application, and it does appear to perform correctly the multithreading, that means with correct performance unlike what I was getting when disabling the threaded RTS.

So I'm pretty sure the fix is correct and fixes completely the problem! I'll keep tuning my app for windows now that a port is finally possible and write here if I find something strange but I am certain I won't. Great work, thanks and I hope this gets merged ASAP!

Maybe @cchantep wants to check too, as he was active in the issue #33 and maybe he didn't notice this PR?

hamishmack added a commit that referenced this pull request Feb 24, 2015
Fix freeze when using threaded RTS on windows
@hamishmack hamishmack merged commit f3c75d5 into gtk2hs:master Feb 24, 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

Successfully merging this pull request may close these issues.

None yet

3 participants