Version française
Home     About     Download     Resources     Contact us    
Browse thread
Uncaught Unix_error.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Romain Beauxis <toots@r...>
Subject: Uncaught Unix_error.
	Hi all !

We have had a strange bug report on our code. Somehow, an Unix.Unix_error 
exception was not caught while it ought to be. See:
  http://savonet.rastageeks.org/ticket/269

We have precisely characterized the issue in the code, and we would like to 
understand its possible origin.

If we look at the code for raising exceptions in otherlib/unixsupport.c, we 
have:
    if (unix_error_exn == NULL) {
      unix_error_exn = caml_named_value("Unix.Unix_error");
      if (unix_error_exn == NULL)
        invalid_argument("Exception Unix.Unix_error not initialized, please 
link unix.cma");
    }

This code fetches the pointer to the named_value representing an 
Unix.Unix_error, and assigns it to a static variable.

However, the threads module also registers an exception of the same name, 
probably because both modules are mutually exclusive.

We believe that the issue is raised because the module that uses Unix.read is 
compiled with one of unix or threads and the application using that module 
with the other one.

In this case, it should be possible that the static value representing the 
exception is initialized with a wrong pointer and  never updated afterwards.

We were unable yet to reproduce the issue on a minimal code, it was caused by 
a portmap scan on the telnet server, which uses Unix.read calls to read from 
the network socket.

We don't really know if this is a known issue, or if there is something to do 
about this from our side, so we wanted to report it here...


Romain