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
Re: [Caml-list] Closer on the Mysterious bug
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-12 (04:27)
From: Jonathan T Bryant <jtbryant@v...>
Subject: Re: [Caml-list] Closer on the Mysterious bug
Wait.  Got it.  One pitfall of the native code compilers:  they don't 
check for stack overflow.  It just turns into a segfault.  When 
compiled to bytecode it crashed with a Stack_overflow exception.  I 
figured this out by chance: I ran into the same problem on another 
program and made the connection...

Jonathan T Bryant wrote:

>Now I've fixed the Unix_error(12, "accept, "") bug: I thought passing 0 
>to select made in wait indefinitely, so I inadvertently created a race 
>condition.  I set it to 0 on all of the calls and that bug disappeared. 
> Also, I'm catching all of the exceptions and printing out a message 
>when I do, but they are closing as (or, for that matter, when) 
>expected.  All that's left is the segfault.  It still occurs at random 
>times: sometimes before any connections are established, sometimes 
>after all the connections have terminated, and sometimes right in the 
>middle.  Sometimes it even freezes for a moment (about 2 sec) before it 
>crashes.  GDB says the segfault is comming from fdset_to_fdlist(), 
>which leads me to  Here's the source of that C function 
>since not everybody will have the same version of OCaml as me (OCaml 
>static value fdset_to_fdlist(value fdlist, fd_set *fdset)
>  value l;
>  value res = Val_int(0);
>  Begin_roots2(l, res);
>    for (l = fdlist; l != Val_int(0); l = Field(l, 1)) {
>      int fd = Int_val(Field(l, 0));
>      if (FD_ISSET(fd, fdset)) {
>        value newres = alloc_small(2, 0);
>        Field(newres, 0) = Val_int(fd);
>        Field(newres, 1) = res;
>        res = newres;
>      }
>    }
>  End_roots();
>  return res;
>Any ideas?
>BTW, If you need to look at my updated code, it's available at 
>--Jonathan Bryant
>  AIM: JonBoy3182
>  ZG214
>Caml-list mailing list. Subscription management:
>Beginner's list:
>Bug reports:

--Jonathan Bryant
  AIM: JonBoy3182