Opened 6 years ago

Closed 6 years ago

#5371 closed bug (fixed)

GHCi crashes calling a C function imported from a static library on Windows

Reported by: simonmar Owned by: simonmar
Priority: high Milestone: 7.4.1
Component: GHCi Version: 7.3
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: GHCi crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Script to reproduce:

cat >f.c <<EOF
int f(int x) { return x*2; }
cat >TestLink.hs <<EOF
module TestLink where
import Foreign.C
foreign import ccall "f" f :: CInt -> IO CInt
test :: IO ()
test = f 42 >>= print
ghc -c f.c -o f.o
ar cqs libfoo.a f.o
echo "test" | ghci libfoo.a TestLink.hs

(which is also the test ghcilink001 I shall be adding shortly as part of the fix for #5289).

Note that this bug only becomes visible after the fix for #5289, because before that GHCi would not load static libraries specified on the command line.

Change History (5)

comment:1 Changed 6 years ago by simonmar

Operating System: Unknown/MultipleWindows

comment:2 Changed 6 years ago by simonmar

Owner: set to simonmar

I have a fix for this.

comment:3 Changed 6 years ago by marlowsd@…

commit 1d012e31577951ff5fe74d0277fabdb08c27929d

Author: Simon Marlow <>
Date:   Wed Nov 30 15:34:00 2011 +0000

    loadArchive: need to allocate executable memory on Win32 (#5371)

 rts/Linker.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

comment:4 Changed 6 years ago by simonmar

Status: newmerge

comment:5 Changed 6 years ago by igloo

difficulty: Unknown
Resolution: fixed
Status: mergeclosed

Patch is included in 7.4 branch.

Note: See TracTickets for help on using tickets.