Ticket #1381 (closed feature request: fixed)

Opened 6 years ago

Last modified 5 months ago

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 Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

Hi

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:  http://www.haskell.org/pipermail/glasgow-haskell-users/2007-May/012613.html

Greetings,

Mads Lindstrøm

Change History

Changed 6 years ago by simonmar

  • milestone set to 6.1

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from low to normal
  • failure set to None/Unknown
  • milestone changed from 6.12.3 to _|_

Changed 5 months 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.

Changed 5 months 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?

Simon

Changed 5 months ago by marlowsd@…

commit 02c4ab049adeb77b8ee0e3b98fbf0f3026eee453

Author: Simon Marlow <marlowsd@gmail.com>
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(-)

Changed 5 months ago by simonmar

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from _|_ to 7.8.1

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.