[GHC] #7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -----------------------------+---------------------------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Component: Compiler (FFI) Version: 7.6.1 | Keywords: qnx unregistered cross-compile Os: Unknown/Multiple | Architecture: arm Failure: Runtime crash | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- I have built an unregistered LLVM cross-compiler for arm-unknown-nto- qnx8.0.0eabi, which I finally got to build using the attached patch. Simple programs no longer crash like they do in registered ARM cross- compilers (as reported on mailing list at http://www.haskell.org/pipermail /ghc-devs/2013-January/000005.html and other places), however the following code does crash: {{{ {-# LANGUAGE ForeignFunctionInterface #-} module Main (main) where import Foreign.Ptr foreign import ccall "wrapper" wrap_refresh :: ( IO ()) -> IO (FunPtr ( IO ())) main :: IO () main = do wrap_refresh (return ()) return () }}} It seems, from experiments, that any code using the "wrapper" imports causes this error: {{{ $ ./Main *** stack smashing detected ***: Main terminated Abort (core dumped) }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -----------------------------+---------------------------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Component: Compiler (FFI) Version: 7.6.1 | Keywords: qnx unregistered cross-compile Os: Unknown/Multiple | Architecture: arm Failure: Runtime crash | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- Comment(by singpolyma): Core file from a similar run and crash, too big to upload to Trac so I put it at https://singpolyma.net/ghc/7621-Main.core.xz -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -----------------------------------------------+---------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (FFI) | Version: 7.6.1 Keywords: qnx unregistered cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -----------------------------------------------+---------------------------- Changes (by simonmar): * difficulty: => Unknown * os: Unknown/Multiple => QNX -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -----------------------------------------------+---------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.6.1 Keywords: qnx unregistered cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -----------------------------------------------+---------------------------- Changes (by simonmar): * milestone: => 7.8.1 Comment: Data point: the test case succeeds for me, with an unregisterised build for Raspberry Pi using both the C backend and LLVM. LLVM version 2.9. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -----------------------------------------------+---------------------------- Reporter: singpolyma | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.6.1 Keywords: qnx unregistered cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -----------------------------------------------+---------------------------- Changes (by simonmar): * status: new => infoneeded Comment: I may have fixed this now, please try again with the latest HEAD. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.6.1 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Changes (by singpolyma): * keywords: qnx unregistered cross-compile => qnx unregisterised cross- compile * status: infoneeded => new Comment: I just build an unregisterised compiler via-C from HEAD (since #7620 is fixed) and it also has this issue. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.7 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Changes (by singpolyma): * version: 7.6.1 => 7.7 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.7 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Comment(by singpolyma): I just built a registerised QNX ARM cross-compiler with llvm-3.0, and this also occurs on binaries produced by that compiler. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.7 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Comment(by simonmar): Ok, someone will need to debug this then. It could be a problem with `libffi`. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers
-------------------------------------------------+--------------------------
Reporter: singpolyma | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler (FFI) | Version: 7.7
Keywords: qnx unregisterised cross-compile | Os: QNX
Architecture: arm | Failure: Runtime crash
Difficulty: Unknown | Testcase:
Blockedby: | Blocking: 7610
Related: |
-------------------------------------------------+--------------------------
Comment(by psycotica0):
I've looked into this, and have decided that whether or not GHC is
correct, libffi is definitely worong.
The following code works under arm-linux-gnueabi and native, but not under
qnx:
{{{
#include

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.7 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Changes (by psycotica0): * cc: 0@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7621: Cross-build for QNX ARM smashes stack when using FunPtr wrappers -------------------------------------------------+-------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (FFI) | Version: 7.7 Keywords: qnx unregisterised cross-compile | Os: QNX Architecture: arm | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: 7610 Related: | -------------------------------------------------+-------------------------- Comment(by igloo): psycotica0, I have no idea. If you're able to sort this out with upstream then that would be great, thanks! -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7621#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC