[GHC] #13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime | Version: 8.0.2 System (Linker) | Keywords: | Operating System: Windows Architecture: | Type of failure: GHCi crash Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I noticed this bug when I installed the `OpenAL` library from Hackage, ran it in GHCi 8.0.2, and segfaulted. Note that I've also reproduced the same error in GHC HEAD. To reproduce this bug, you'll need MSYS2. First install OpenAL: {{{ pacman -S mingw-w64-$(uname -m)-openal }}} With this Haskell file: {{{#!hs module Main (main) where import Foreign.C.Types foreign import ccall unsafe "alGetError" alGetError :: IO CInt main :: IO () main = alGetError >>= print }}} You can compile and run it without issue, using either the flag `-llibopenal` or `-lopenal` to link against OpenAL: {{{ $ ghc-8.0.2/bin/ghc -fforce-recomp -llibopenal OpenAL.hs [1 of 1] Compiling Main ( OpenAL.hs, OpenAL.o ) Linking OpenAL.exe ... $ ./OpenAL 40964 $ ghc-8.0.2/bin/ghc -fforce-recomp -lopenal OpenAL.hs $ ./OpenAL 40964 $ ghc/inplace/bin/ghc-stage2 -fforce-recomp -llibopenal OpenAL.hs [1 of 1] Compiling Main ( OpenAL.hs, OpenAL.o ) Linking OpenAL.exe ... $ ./OpenAL 40964 $ ghc/inplace/bin/ghc-stage2 -fforce-recomp -lopenal OpenAL.hs [1 of 1] Compiling Main ( OpenAL.hs, OpenAL.o ) Linking OpenAL.exe ... $ ./OpenAL 40964 }}} With GHCi, however, it gets funkier. If you pass the `-lopenal` flag, it seems to work OK: {{{ $ ghc-8.0.2/bin/runghc -lopenal OpenAL.hs 40964 $ ghc/inplace/bin/runghc -lopenal OpenAL.hs 40964 }}} But if you use the `-llibopenal` flag, it segfaults! {{{ $ runghc -llibopenal -v3 OpenAL.hs Glasgow Haskell Compiler, Version 8.0.2, stage 2 booted by GHC version 8.0.1 Using binary package database: C:\Users\RyanGlScott\Software\ghc-8.0.2\lib\package.conf.d\package.cache Using binary package database: C:\Users\RyanGlScott\AppData\Roaming\ghc\x86_64-mingw32-8.0.2\package.conf.d\package.cache loading package database C:\Users\RyanGlScott\Software\ghc-8.0.2\lib\package.conf.d loading package database C:\Users\RyanGlScott\AppData\Roaming\ghc\x86_64-mingw32-8.0.2\package.conf.d wired-in package ghc-prim mapped to ghc-prim-0.5.0.0 wired-in package integer-gmp mapped to integer-gmp-1.0.0.1 wired-in package base mapped to base-4.9.1.0 wired-in package rts mapped to rts wired-in package template-haskell mapped to template-haskell-2.11.1.0 wired-in package ghc mapped to ghc-8.0.2 wired-in package dph-seq not found. wired-in package dph-par not found. Hsc static flags: *** Parser [source]: !!! Parser [source]: finished in 0.00 milliseconds, allocated 0.212 megabytes *** Desugar: *** Simplify [expr]: !!! Simplify [expr]: finished in 0.00 milliseconds, allocated 0.133 megabytes *** CorePrep [expr]: !!! CorePrep [expr]: finished in 0.00 milliseconds, allocated 2.731 megabytes *** ByteCodeGen [Ghci1]: !!! ByteCodeGen [Ghci1]: finished in 0.00 milliseconds, allocated 0.182 megabytes *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "mingw32.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingw32.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingw32.dll.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "mingw32.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingw32.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingw32.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "mingwex.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingwex.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingwex.dll.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "mingwex.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingwex.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\ghc-prim-0.5.0.0" "--print- file-name" "libmingwex.a" Loading package ghc-prim-0.5.0.0 ... linking ... done. Loading package integer-gmp-1.0.0.1 ... linking ... done. *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "mingw32.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingw32.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingw32.dll.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "mingw32.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingw32.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingw32.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "mingwex.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingwex.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingwex.dll.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "mingwex.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingwex.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "-BC:\Users\RyanGlScott\Software\ghc-8.0.2\lib\base-4.9.1.0" "--print- file-name" "libmingwex.a" Loading package base-4.9.1.0 ... linking ... done. *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "libopenal.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "liblibopenal.lib" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "liblibopenal.dll.a" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "libopenal.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "liblibopenal.dll" *** gcc: "C:\Users\RyanGlScott\Software\ghc-8.0.2\lib/../mingw/bin/gcc.exe" "-fno- stack-protector" "-DTABLES_NEXT_TO_CODE" "--print-file-name" "liblibopenal.a" Loading object (dynamic) libopenal ... ghc.exe: addDLL: libopenal (Win32 error 126): The specified module could not be found. }}} At that point, GHC segfaults and force-quits (if you run this on PowerShell, a "ghc.exe has stopped working" message box will pop up). I don't know if #12771 is relevant. You can't test this on GHC 8.0.1 or earlier because they didn't have support for Windows import libs, which OpenAL uses. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * owner: => Phyx- Comment: Thanks for the report @RyanGIScott -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: T13082_good, | T13082_fail Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2941 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * testcase: => T13082_good, T13082_fail * status: new => patch * differential: => Phab:D2941 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: T13082_good, | T13082_fail Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2941 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"331f88d0d878eae926b3c1c61a3ff344916b62ed/ghc" 331f88d0/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="331f88d0d878eae926b3c1c61a3ff344916b62ed" Fix abort and import lib search on Windows Summary: Apparently `sysErrorBelch` doesn't terminate the program anymore making previously unreachable code now execute. If a dll is not found the error message we return needs to be a heap value. Secondly also allow the pattern `lib<name>` to be allowed for finding an import library with the name `lib<name>.dll.a`. Test Plan: ./validate, new tests T13082_good and T13082_fail Reviewers: austin, RyanGlScott, hvr, erikd, simonmar, bgamari Reviewed By: RyanGlScott, bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2941 GHC Trac Issues: #13082 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: T13082_good, | T13082_fail Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2941 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"4bfe3d4d13806202be7fc4a90106b200171588e6/ghc" 4bfe3d4d/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="4bfe3d4d13806202be7fc4a90106b200171588e6" Add missing test files for T13082. Summary: Add two missing test files for T13082. The reason they were missing is because the .gitignore contains a very harmful and broad wildcard `foo*`. Why? Test Plan: make test TEST="T13082_good T13082_fail" Reviewers: austin, bgamari, simonmar, erikd Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2981 GHC Trac Issues: #13082 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13082: GHCi segfaults with the flag -llibopenal, but not with -lopenal -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: T13082_good, | T13082_fail Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2941 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13082#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC