Opened 8 years ago

Closed 3 years ago

#1381 closed feature request (fixed)

Add terminateStmt to "GHC as a library"

Reported by: guest Owned by:
Priority: normal Milestone: 7.8.1
Component: GHC API Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by simonpj)


I would like an extension to the "GHC as a library" API, so that if I have done:

  runStmt someStatement

I can prematurely terminate the execution.

I have posted this request on GHC-users@… and a more thorough explanation can be found there:


Mads Lindstrøm

Change History (10)

comment:1 Changed 8 years ago by simonmar

  • Milestone set to 6.1

comment:2 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 7 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple

comment:4 Changed 6 years ago by igloo

  • Milestone changed from 6.10 branch to 6.12 branch

comment:5 Changed 5 years ago by igloo

  • Milestone changed from 6.12 branch to 6.12.3

comment:6 Changed 5 years ago by igloo

  • Milestone changed from 6.12.3 to _|_
  • Priority changed from low to normal
  • Type of failure set to None/Unknown

comment:7 Changed 3 years ago by edsko

There is currently no good workaround for this, because Panic.interruptTargetThread is not exported, and hence we cannot find the ThreadId of the thread spawned by runStmt. We can avoid runStmt spawning a thread at all by disabling Opt_GhciSandbox so that we can throw UserInterrupt to the thread that calls runStmt, but that means that the debugging facilities don't work anymore.

comment:8 Changed 3 years ago by simonpj

  • Description modified (diff)

I'm not familiar with the details, but it sounds as if you are.... any chance of a patch?


comment:9 Changed 3 years ago by marlowsd@…

commit 02c4ab049adeb77b8ee0e3b98fbf0f3026eee453

Author: Simon Marlow <[email protected]>
Date:   Thu Dec 20 09:18:49 2012 +0000

    Redirect asynchronous exceptions to the sandbox thread in runStmt (#1381)
    See comment for details.
    We no longer use pushInterruptTargetThread/popInterruptTargetThread,
    so these could go away in due course.

 compiler/main/InteractiveEval.hs |   43 ++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 11 deletions(-)

comment:10 Changed 3 years ago by simonmar

  • Milestone changed from _|_ to 7.8.1
  • Resolution set to fixed
  • Status changed from new to closed

I believe the above patch fixes this ticket, because you can now just throw an exception to the thread that calls runStmt and the right thing will happen: runStmt will return with RunException e where e is the exception you threw.

Note: See TracTickets for help on using tickets.