Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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:

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 
    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 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 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...