Ticket #5993 (closed bug: fixed)

Opened 14 months ago

Last modified 13 months ago

Segfault with threaded runtime and low +RTS -k

Reported by: ksf Owned by:
Priority: normal Milestone: 7.4.2
Component: Compiler Version: 7.4.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Runtime crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Consider this minimal test case:

main = putStrLn "Hello, World!" 

compile and run:

ghc -threaded hello.hs -rtsopts && ./hello +RTS -k8
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking hello ...
Hello, World!
zsh: segmentation fault  ./hello +RTS -k8

And another one for the non-threaded runtime:

import Control.Concurrent
main = do
    forkIO $ putStrLn "Hello, World!"
ghc hello.hs -rtsopts && ./hello +RTS -k8
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking hello ...
Hello, World!
zsh: segmentation fault  ./hello +RTS -k8

Do note that main = return () works for the threaded runtime, and main = putStrLn "Hello, World!" for the unthreaded.

Now one could argue that -k is an insanely low setting, but I arrived there by tracking down BS.unpack mutating its underlying buffer (via unsafePackCStringFinalizer) in the first and last handfull of bytes into random, but replicable, junk, and trying to minimise the randomness of *when* that happens led me to the GC.

...which leads me to the hope that those two bugs are actually one and the same in different guises. The test case for the mutating behaviour is, alas, quite non-minimal.

Change History

Changed 13 months ago by marlowsd@…

commit 5eabdc1675b8b5bc9fcdfb96ab63d14d42ca2d5b

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Thu Apr 12 11:41:17 2012 +0100

    Fix crash with tiny initial stack size (#5993)

 rts/Threads.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Changed 13 months ago by simonmar

  • status changed from new to merge
  • difficulty set to Unknown
  • milestone set to 7.4.2

Changed 13 months ago by pcapriotti

  • status changed from merge to closed
  • resolution set to fixed

Merged as 48c3d271fe14380000f81f21e03bf7d77b9af16f.

Note: See TracTickets for help on using tickets.