caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Mysterious bug
@ 2005-12-11  3:30 Jonathan Bryant
  2005-12-11  4:32 ` [Caml-list] " Brian Hurt
  2005-12-11 11:11 ` Olivier Andrieu
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Bryant @ 2005-12-11  3:30 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

Everybody,

I'm working on my client/server library and I've run into a rather
elusive bug.  It may be elusive because my skills with GDB are rather
shoddy (usually I'm pretty good at achieving my goal of not needing to
use it).

The attachment is my code for the library (as well as a small build
script and tester).  It's documented in the Acceptor module, but when I
run the server under high loads (10 thread pinging it 1,000,000 times or
so each), one of three things happens:
1. Nothing (works like it should)
2. Unix.accept raises an Unix.Unix_error(12, "accept", "") at some
random time (sometimes, I believe, after all of the connections have
been made, but I feel very wrong in thinking this)
3. Segmentation Fault at a random time.

These bugs sometimes come up immediately into execution and sometimes 5
minutes or so into execution.  I don't know if this is a bug in my
tester, my library, OCaml, or Linux.  Any ideas?  I think it may just be
that I've been staring at the code for too long and need another set of
eyes to look at it...

--Jonathan Bryant

[-- Attachment #2: clientServer.tar.gz --]
[-- Type: application/x-compressed-tar, Size: 6896 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Mysterious bug
  2005-12-11  3:30 Mysterious bug Jonathan Bryant
@ 2005-12-11  4:32 ` Brian Hurt
  2005-12-11 11:16   ` Christophe TROESTLER
  2005-12-11 11:11 ` Olivier Andrieu
  1 sibling, 1 reply; 6+ messages in thread
From: Brian Hurt @ 2005-12-11  4:32 UTC (permalink / raw)
  To: Jonathan Bryant; +Cc: caml-list



On Sat, 10 Dec 2005, Jonathan Bryant wrote:

> 2. Unix.accept raises an Unix.Unix_error(12, "accept", "") at some
> random time (sometimes, I believe, after all of the connections have
> been made, but I feel very wrong in thinking this)

Not sure if this helps, but errno 12 is ENOMEM, which means the kernel is 
running out of memory.  I'm not sure what would cause it, however.

Brian


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Mysterious bug
  2005-12-11  3:30 Mysterious bug Jonathan Bryant
  2005-12-11  4:32 ` [Caml-list] " Brian Hurt
@ 2005-12-11 11:11 ` Olivier Andrieu
  1 sibling, 0 replies; 6+ messages in thread
From: Olivier Andrieu @ 2005-12-11 11:11 UTC (permalink / raw)
  To: jtbryant; +Cc: caml-list

 Jonathan Bryant [Saturday 10 December 2005] :
 >
 > Everybody,
 > 
 > I'm working on my client/server library and I've run into a rather
 > elusive bug.  It may be elusive because my skills with GDB are rather
 > shoddy (usually I'm pretty good at achieving my goal of not needing to
 > use it).
 > 
 > The attachment is my code for the library (as well as a small build
 > script and tester).  It's documented in the Acceptor module, but when I
 > run the server under high loads (10 thread pinging it 1,000,000 times or
 > so each), one of three things happens:
 > 1. Nothing (works like it should)
 > 2. Unix.accept raises an Unix.Unix_error(12, "accept", "") at some
 > random time (sometimes, I believe, after all of the connections have
 > been made, but I feel very wrong in thinking this)

12 is EINVAL, and the accept(2) manpage says:

  EINVAL Socket is not listening for connections.

So I guess your code has some ordering issues, you accept()
either before you listen() or after you shutdown().

-- 
   Olivier


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Mysterious bug
  2005-12-11  4:32 ` [Caml-list] " Brian Hurt
@ 2005-12-11 11:16   ` Christophe TROESTLER
  2005-12-11 14:33     ` Brian Hurt
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe TROESTLER @ 2005-12-11 11:16 UTC (permalink / raw)
  To: jtbryant, caml-list

On Sat, 10 Dec 2005, Brian Hurt <bhurt@spnz.org> wrote:
> 
> On Sat, 10 Dec 2005, Jonathan Bryant wrote:
> 
> > 2. Unix.accept raises an Unix.Unix_error(12, "accept", "") at some
> > random time (sometimes, I believe, after all of the connections have
> > been made, but I feel very wrong in thinking this)
> 
> Not sure if this helps, but errno 12 is ENOMEM, which means the kernel is 
> running out of memory.  I'm not sure what would cause it, however.

# (Obj.magic 12 : Unix.error);;
- : Unix.error = Unix.EINVAL

man accept:

	EINVAL
		Socket is not listening for connections.

Hope it helps,
ChriS


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Mysterious bug
  2005-12-11 11:16   ` Christophe TROESTLER
@ 2005-12-11 14:33     ` Brian Hurt
  2005-12-11 15:15       ` Christophe TROESTLER
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Hurt @ 2005-12-11 14:33 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: jtbryant, caml-list



On Sun, 11 Dec 2005, Christophe TROESTLER wrote:

> On Sat, 10 Dec 2005, Brian Hurt <bhurt@spnz.org> wrote:
>>
>> On Sat, 10 Dec 2005, Jonathan Bryant wrote:
>>
>>> 2. Unix.accept raises an Unix.Unix_error(12, "accept", "") at some
>>> random time (sometimes, I believe, after all of the connections have
>>> been made, but I feel very wrong in thinking this)
>>
>> Not sure if this helps, but errno 12 is ENOMEM, which means the kernel is
>> running out of memory.  I'm not sure what would cause it, however.
>
> # (Obj.magic 12 : Unix.error);;
> - : Unix.error = Unix.EINVAL
>
> man accept:
>
> 	EINVAL
> 		Socket is not listening for connections.

A) This makes more sense than ENOMEM.

B) Does Ocaml remap the errnos?  Because I got ENOMEM by looking at 
/usr/include/asm-generic/errno-base.h, from which I get:

#define ENOMEM          12      /* Out of memory */

Brian


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Mysterious bug
  2005-12-11 14:33     ` Brian Hurt
@ 2005-12-11 15:15       ` Christophe TROESTLER
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe TROESTLER @ 2005-12-11 15:15 UTC (permalink / raw)
  To: bhurt; +Cc: jtbryant, caml-list

On Sun, 11 Dec 2005, Brian Hurt <bhurt@spnz.org> wrote:
> 
> B) Does Ocaml remap the errnos?

This is not an errno but the value of the constructor as integer
(i.e. Unix.EINVAL is the number 12 constructor of Unix.error -- the
first one being numbered 0).

ChriS


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-12-11 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-11  3:30 Mysterious bug Jonathan Bryant
2005-12-11  4:32 ` [Caml-list] " Brian Hurt
2005-12-11 11:16   ` Christophe TROESTLER
2005-12-11 14:33     ` Brian Hurt
2005-12-11 15:15       ` Christophe TROESTLER
2005-12-11 11:11 ` Olivier Andrieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).