Opened 3 years ago

Closed 2 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 Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Script to reproduce:

cat >f.c <<EOF
int f(int x) { return x*2; }
EOF
cat >TestLink.hs <<EOF
module TestLink where
import Foreign.C
foreign import ccall "f" f :: CInt -> IO CInt
test :: IO ()
test = f 42 >>= print
EOF
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 3 years ago by simonmar

  • Operating System changed from Unknown/Multiple to Windows

comment:2 Changed 2 years ago by simonmar

  • Owner set to simonmar

I have a fix for this.

comment:3 Changed 2 years ago by marlowsd@…

commit 1d012e31577951ff5fe74d0277fabdb08c27929d

Author: Simon Marlow <marlowsd@gmail.com>
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 2 years ago by simonmar

  • Status changed from new to merge

comment:5 Changed 2 years ago by igloo

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from merge to closed

Patch is included in 7.4 branch.

Note: See TracTickets for help on using tickets.