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,268
    • Issues 4,268
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 408
    • Merge Requests 408
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18951

Closed
Open
Opened Nov 14, 2020 by fendor@fendorDeveloper

Ghci does not terminate cleanly after Stack Overflow Error

Summary

In certain cases, after a Stack Overflow occurs, Ghci threads are not correctly cleaned up, letting them linger with 100% CPU usage.

Steps to reproduce

Content of Err.hs:

data X a = X
instance Show a => Show (X a) where
x = show (X :: X Int)

Invoke:

> ghci Err.hs +RTS -M2G -K100M -RTS -e "x"
Err.hs:2:10-29: warning: [-Wmissing-methods]
    • No explicit implementation for
        either ‘showsPrec’ or ‘show’
    • In the instance declaration for ‘Show (X a)’
  |
2 | instance Show a => Show (X a) where
  |          ^^^^^^^^^^^^^^^^^^^^
<interactive>: stack overflow

However, this computation does not terminate and you can verify in top or htop that there is at least one ghc thread with 100% CPU usage.

Note, that you can get the desired behaviour, if you omit the typeclass constraint on a in the Instance declaration. (Assume file Ok.hs)

data X a = X
instance Show (X a) where
x = show (X :: X Int)

Now the invocation ghci Ok.hs +RTS -M2G -K100M -RTS -e "x" terminates with a Stack Overflow correctly.

Moreover, reducing the amount of stack (e.g. to -K1M) also solves the issue.

Expected behavior

Eventually terminate with a stack overflow.

What do you expect the reproducer described above to do?

It will not terminate and also not react on ctrl+c or other signals. You have to send sigkill to it.

Environment

  • GHC version used: 8.8.4

Optional:

  • Operating System: NixOS
  • System Architecture: x86_64
Edited Nov 14, 2020 by fendor
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18951