Re: [GHC] #3236: Would be nice if rts_lock (or similar) would fail when the RTS is not started

2009-05-19 Thread GHC
#3236: Would be nice if rts_lock (or similar) would fail when the RTS is not
started
-+--
Reporter:  duncan|Owner:  simonmar
Type:  feature request   |   Status:  closed  
Priority:  normal|Milestone:  6.12.1  
   Component:  Runtime System|  Version:  6.11
Severity:  minor |   Resolution:  fixed   
Keywords:|   Difficulty:  Unknown 
Testcase:|   Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |  
-+--
Changes (by simonmar):

  * status:  new = closed
  * resolution:  = fixed
  * milestone:  = 6.12.1

Comment:

 Done:

 {{{
 Mon May 18 03:41:08 PDT 2009  Simon Marlow marlo...@gmail.com
   * Fix #3236: emit a helpful error message when the RTS has not been
 initialised
 }}}

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3236#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #3236: Would be nice if rts_lock (or similar) would fail when the RTS is not started

2009-05-16 Thread GHC
#3236: Would be nice if rts_lock (or similar) would fail when the RTS is not
started
-+--
Reporter:  duncan|  Owner:  
Type:  feature request   | Status:  new 
Priority:  normal|  Component:  Runtime System  
 Version:  6.11  |   Severity:  minor   
Keywords:|   Testcase:  
  Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-+--
 If you export a Haskell function and then call it from C code you have got
 to remember to start up the RTS before calling the exported C function,
 otherwise it segfaults.

 As a slightly nicer way of reminding people to initialise the RTS, perhaps
 one of the functions on the code path for calling exported functions (ie
 the calls in the _stub.c files) could check if the RTS is started and if
 not do something a little nicer than segfault.

 The code typically looks like
 {{{
 cap=rts_lock();
 cap=rts_evalIO(cap,
   rts_apply(cap,(HaskellObj)runIO_closure,
 rts_apply(cap,Foo_zdffoozuads_closure,
   rts_mkInt(cap,a1))) ,ret);
 rts_checkSchedStatus(foo,cap);
 cret=rts_getInt(ret);
 }}}
 The first bit to segfault is `allocateLocal`, probably inside `rts_mkInt`.
 Note that `rts_lock` succeeds and returns a non-null capability.


 On similar lines, we might want to think about the use case of building
 Haskell libs that export C functions to be used by other projects and ways
 to make initialising that library either nicer or automatic. We all
 complain when we use C libs that require a global initialiser (implying
 some global state) and yet that's exactly what we impose on callers.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3236
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs