#2961: Incorrect FFI code generated with -O
---------------------+------------------------------------------------------
Reporter: sjanssen | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (FFI)
Version: 6.10.1 | Severity: normal
Keywords: | Testcase:
Os: Linux | Architecture: x86_64 (amd64)
---------------------+------------------------------------------------------
GHC 6.10.1 seems to generate incorrect code for createWindow in X11-1.4.3
on
x86_64 when optimizations are on.
{{{
$ ghc-6.10.1 -fforce-recomp --make simple.hs -O0 -o simple
$ ghc-6.10.1 -fforce-recomp --make simple.hs -O -o simple_optimized
}}}
When built with no optimizations, the program succeeds:
{{{
$ ./simple
(33554433,Display 0x0000000001192dd0,Screen 0x0000000001193a40,194)
}}}
When built with optimizations, the X server sends an error about an
invalid
parameter to a XCreateWindow call:
{{{
$ ./simple_optimized
(33554433,Display 0x0000000000b91dd0,Screen 0x0000000000b92a40,194)
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 1 (X_CreateWindow)
Serial number of failed request: 7
Current serial number in output stream: 8
}}}
We set a breakpoint at XCreateWindow to check the arguments passed, note
that
depth takes the correct value in the non-optimized version:
{{{
$ gdb simple
(gdb) break XCreateWindow
(gdb) run
...
Breakpoint 1, XCreateWindow (dpy=0x172bde0, parent=194, x=0, y=0,
width=100, height=100,
borderWidth=0, depth=24, class=1, visual=0x17333d0, valuemask=512,
attributes=0x7f920a77e040) at ../../src/Window.c:115
115 ../../src/Window.c: No such file or directory.
in ../../src/Window.c
}}}
The optimized version has "depth=38044640", which is total nonsense. The
value
seems to change from run to run.
{{{
$ gdb simple_optimized
(gdb) break XCreateWindow
(gdb) run
...
Breakpoint 1, XCreateWindow (dpy=0x2440df0, parent=194, x=0, y=0,
width=100, height=100,
borderWidth=0, depth=38044640, class=1, visual=0x24483e0,
valuemask=512,
attributes=0x7f84f577e040) at ../../src/Window.c:115
115 ../../src/Window.c: No such file or directory.
in ../../src/Window.c
}}}
We discovered this bug in xmonad (http://xmonad.org/bugs/226), and have
temporarily worked around it by using Cabal's --disable-optimization flag.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2961>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs