[Haskell-cafe] Top Level <-

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon Sep 1 02:16:39 EDT 2008

On 2008 Sep 1, at 1:33, Ganesh Sittampalam wrote:
> On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote:
>> On 2008 Aug 31, at 13:20, Ganesh Sittampalam wrote:
>>> I'm afraid I don't see how this generalises to sharing something  
>>> across an entire process where the things that want to do the  
>>> sharing are not in or controlled by the same shared library. In  
>>> particular the filehandle structures required for buffered I/O  
>>> need to be common to every single piece of code in the process  
>>> that might want to use them, no matter what language or language  
>>> implementation that code uses.
>> For that you probably want to look at how ld.so.1 and libc interact  
>> to share the malloc pool and the stdin/stdout/stderr, among others.
> If buffered IO is handled by libc rather than by specific language  
> runtimes, then the same mechanism of using global variables inside  
> libc would work fine; but this technique doesn't extend to providing  
> process-scope shared state for library code that might be loaded  
> multiple times with no knowledge of the other instances.

True.  If you want to allow for that, you must do it yourself.  (I've  
been bitten by this; older ssh built against older heimdal would load  
two different versions of the crypto libraries, ssh would initialize  
one, heimdal would use the other (the initialized flag being global,  
but the buffers different sizes) and presto, core dump.)

This is in large part what the discussion is about:  making it  
possible to write such properly without having to delegate it across  
the FFI as C code.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list