Opened 8 years ago

Closed 8 years ago

#3473 closed bug (fixed)

System.Posix.Semaphore shouldn't create finalizers with Foreign.newForeignPtr

Reported by: kaol Owned by: simonmar
Priority: normal Milestone: 6.12.1
Component: libraries/unix Version: 6.10.4
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Running this program

import System.Posix.Semaphore

main = do
        s <- semOpen "c" (OpenSemFlags True False) 0666 1
        semThreadWait s
        v <- semGetValue s
        putStrLn "Type!"
        a <- getLine
        putStrLn $ "OK, " ++ a
        semPost s

fails like this:

Type!
abc
OK, abc
sem: error: a C finalizer called back into Haskell.
This was previously allowed, but is disallowed in GHC 6.10.2 and later.
To create finalizers that may call back into Haskll, use
Foreign.Concurrent.newForeignPtr instead of Foreign.newForeignPtr.

The attached patch for libraries/unix/System/Posix/Semaphore.hsc should fix this.

Attachments (1)

semaphore_ffi_fix (1.2 KB) - added by kaol 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by kaol

Attachment: semaphore_ffi_fix added

comment:1 Changed 8 years ago by simonmar

difficulty: Unknown
Milestone: 6.12.1
Owner: set to simonmar

I'll validate and push; thanks.

comment:2 Changed 8 years ago by simonmar

Resolution: fixed
Status: newclosed

Applied

Tue Sep  8 07:25:36 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * Use Foreign.Concurrent for Haskell finalizers (#3473)
Note: See TracTickets for help on using tickets.