[GHC] #14912: UnsafeReenter test fails with threaded1 and threaded2

GHC ghc-devs at haskell.org
Wed Aug 29 07:04:08 UTC 2018


#14912: UnsafeReenter test fails with threaded1 and threaded2
-----------------------------------+--------------------------------------
        Reporter:  alpmestan       |                Owner:  (none)
            Type:  bug             |               Status:  new
        Priority:  normal          |            Milestone:
       Component:  Runtime System  |              Version:  8.5
      Resolution:                  |             Keywords:
Operating System:  Linux           |         Architecture:  x86_64 (amd64)
 Type of failure:  None/Unknown    |            Test Case:
      Blocked By:                  |             Blocking:
 Related Tickets:  #14743          |  Differential Rev(s):
       Wiki Page:                  |
-----------------------------------+--------------------------------------
Changes (by osa1):

 * cc: simonmar (added)
 * related:   => #14743


Comment:

 This still happens with GHC HEAD, but only with threaded runtime.

 {{{
 $ ghc-stage2 UnsafeReenter.hs UnsafeReenterC.c -fforce-recomp -threaded
 [1 of 1] Compiling Main             ( UnsafeReenter.hs, UnsafeReenter.o )
 Linking UnsafeReenter ...

 $ ./UnsafeReenter
 In Haskell
 in C
 ^C^C
 }}}

 Interestingly, if I add `-N2` the program terminates, but not with the
 error
 message as expected!

 {{{
 $ ./UnsafeReenter +RTS -N2
 In Haskell
 in C
 Back in Haskell
 Finished
 }}}

 I checked Haskell 2010 and this program actually has an undefined
 behavior:
 (section 8.4.3)

 > safe call is less efficient, but guarantees to leave the Haskell system
 in a
 > state that allows callbacks from the external code. In contrast, an
 unsafe
 > call, while carrying less overhead, must not trigger a callback into the
 > Haskell system. If it does, the system behaviour is undefined.

 So both outputs above are actually fine. But perhaps we still want to
 catch
 Haskell calls from unsafe FFI calls in the current implementation? Simon,
 any
 ideas?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14912#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list