Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,384
    • Issues 4,384
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 368
    • Merge Requests 368
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10199

Closed
Open
Opened Mar 27, 2015 by adeon@trac-adeon

Sending SIGINT to a program that uses forkOS may crash with various errors

This is the program:

module Main ( main ) where

import Control.Concurrent
import Control.Monad

main :: IO ()
main = recursive 0
  where
    recursive n = do
        tid <- forkIO $ do
            replicateM_ 100 $ forkOS $ return ()
        replicateM_ (n `mod` 1000) yield
        recursive (n+1)

I was trying to investigate a potential issue with leaking StablePtrs in forkOS but that's another story.

Compile with ghc Main.hs -prof -auto-all -threaded -o Main. Run as ./Main +RTS -h (I don't know if it's absolutely necessary to turn heap profiling on but I have more trouble getting these error messages without it).

Then, stop the program with SIGINT (by pressing CTRL+C or otherwise). The program sometimes crashes and produces one of the these two error messages:

Main: internal error: RELEASE_LOCK: I do not own this lock: rts/Task.c 242
    (GHC version 7.10.1 for x86_64_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Main: newBoundTask: RTS is not initialised; call hs_init() first

Sometimes the message may be slightly garbled (notice double internal error below):

Î: internal error: Main: internal error: RELEASE_LOCK: I do not own this lock: rts/Task.c 242
    (GHC version 7.10.1 for x86_64_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Replacing forkOS with forkIO seems to stop the messages. I can't reproduce this on FreeBSD. I'm using the downloaded binaries of 7.10.1 from GHC site on Arch Linux.

I used this simple bash script to see more of these messages because it won't crash reliably:

#!/bin/bash

while true; do
    timeout -s INT 0.2 ./Main +RTS -h
done
Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC simonmar
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#10199