Ticket #1112 (closed defect: fixed)
"Xlib: unexpected async reply" with threaded RTS and --sync command line parameter
| Reported by: | guest | Owned by: | somebody |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.0 |
| Component: | general (Gtk+, Glib) | Version: | 0.9.12 |
| Keywords: | threads | Cc: |
Description
A trivial program which uses unsafeInitGUIForThreadedRTS, and doesn't even start additional threads, causes the above error message when started with the "--sync" command line parameter. It has to be compiled with "-threaded", but multithreading doesn't need to be enabled at runtime for the error to occur. The same problem occurs even without the "--sync" parameter, but only in a much more complex program. All the parameter does is tell X to report errors synchronously.
Calling XInitThreads at the start of main makes the error disappear, which indicates that Haskell calls Gtk (which in turn calls X) from multiple OS threads.
The attached archive contains three versions of the same program:
- broken.hs prints the error and hangs. Some fierce resizing (i. e. Expose events) may be necessary to trigger the error.
- working.hs merely adds a call to XInitThreads and doesn't hang regardless of the amount of resizing.
- test.c is an equivalent program in C, which works fine without calling XInitThreads.