caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right.
@ 2011-03-08  2:17 Arlen Cuss
  2011-03-08  2:22 ` Arlen Cuss
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arlen Cuss @ 2011-03-08  2:17 UTC (permalink / raw)
  To: caml-list

Hi all,

I'm getting bizarre errors in a program which multiplexes on 50-100
sockets (some Unix domain, some TCP), where an error will apparently
occur in "write", but the entire backtrace is limited to 'format.ml':

backtrace: Raised at file "format.ml", line 194, characters 15-26
Called from file "format.ml", line 420, characters 8-33
Called from file "format.ml", line 435, characters 6-24

The backtrace does describe a correct path through format.ml:

194    | _ -> raise Empty_queue

420   match peek_queue state.pp_queue with

435   try advance_loop state with

It's hard to determine what's going on, because for some reason the
backtrace is limited to this file, and none of my own code. I'm a bit
lost as to how these errors are being raised:

Exception Unix.Unix_error(31, "write", "") occurred
Exception Unix.Unix_error(56, "write", "") occurred

Both are occurring with the same reported backtrace; the former is Unix
error EMLINK (too many links), the latter EISCONN (socket is connected);
the strange thing is that *neither* of these errors should be throwable
on a write() call!

I've ensured I'm correctly compiling with debug info, so I'm a bit lost.
I can only assume a sprintf or similar call somewhere is going haywire.

Anyone seen anything like this before?

Best,
Arlen


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

* Re: [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right.
  2011-03-08  2:17 [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right Arlen Cuss
@ 2011-03-08  2:22 ` Arlen Cuss
  2011-03-08 14:35 ` Gerd Stolpmann
       [not found] ` <1001695803.480327.1299594992792.JavaMail.root@zmbs4.inria.fr>
  2 siblings, 0 replies; 5+ messages in thread
From: Arlen Cuss @ 2011-03-08  2:22 UTC (permalink / raw)
  To: caml-list

I eat my words. :( I was doing the Printexc.get_backtrace () call
immediately after a printf statement (printing information about the
exception), so I got a stack for that instead!

Sorry for the noise!

Arlen

On Tue, 2011-03-08 at 13:17 +1100, Arlen Cuss wrote:
> Hi all,
> 
> I'm getting bizarre errors in a program which multiplexes on 50-100
> sockets (some Unix domain, some TCP), where an error will apparently
> occur in "write", but the entire backtrace is limited to 'format.ml':
> 
> backtrace: Raised at file "format.ml", line 194, characters 15-26
> Called from file "format.ml", line 420, characters 8-33
> Called from file "format.ml", line 435, characters 6-24
> 
> The backtrace does describe a correct path through format.ml:
> 
> 194    | _ -> raise Empty_queue
> 
> 420   match peek_queue state.pp_queue with
> 
> 435   try advance_loop state with
> 
> It's hard to determine what's going on, because for some reason the
> backtrace is limited to this file, and none of my own code. I'm a bit
> lost as to how these errors are being raised:
> 
> Exception Unix.Unix_error(31, "write", "") occurred
> Exception Unix.Unix_error(56, "write", "") occurred
> 
> Both are occurring with the same reported backtrace; the former is Unix
> error EMLINK (too many links), the latter EISCONN (socket is connected);
> the strange thing is that *neither* of these errors should be throwable
> on a write() call!
> 
> I've ensured I'm correctly compiling with debug info, so I'm a bit lost.
> I can only assume a sprintf or similar call somewhere is going haywire.
> 
> Anyone seen anything like this before?
> 
> Best,
> Arlen
> 
> 



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

* Re: [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right.
  2011-03-08  2:17 [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right Arlen Cuss
  2011-03-08  2:22 ` Arlen Cuss
@ 2011-03-08 14:35 ` Gerd Stolpmann
       [not found] ` <1001695803.480327.1299594992792.JavaMail.root@zmbs4.inria.fr>
  2 siblings, 0 replies; 5+ messages in thread
From: Gerd Stolpmann @ 2011-03-08 14:35 UTC (permalink / raw)
  To: Arlen Cuss; +Cc: caml-list

Am Dienstag, den 08.03.2011, 13:17 +1100 schrieb Arlen Cuss:

> Exception Unix.Unix_error(31, "write", "") occurred
> Exception Unix.Unix_error(56, "write", "") occurred
> 
> Both are occurring with the same reported backtrace; the former is Unix
> error EMLINK (too many links), the latter EISCONN (socket is connected);
> the strange thing is that *neither* of these errors should be throwable
> on a write() call!

That's not quite correct.

Error 31 is EPIPE. Error 56 is ECONNRESET. You can easily find out by
typing in the toploop:

# (Obj.magic 31: Unix.error);;
- : Unix.error = Unix.EPIPE
# (Obj.magic 56: Unix.error);;
- : Unix.error = Unix.ECONNRESET

The error numbers are not the official Unix ones, but something that
ocaml uses internally.

Gerd


> 
> I've ensured I'm correctly compiling with debug info, so I'm a bit lost.
> I can only assume a sprintf or similar call somewhere is going haywire.
> 
> Anyone seen anything like this before?
> 
> Best,
> Arlen
> 
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


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

* Re: [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right.
       [not found] ` <1001695803.480327.1299594992792.JavaMail.root@zmbs4.inria.fr>
@ 2011-03-08 21:28   ` Fabrice Le Fessant
  2011-03-08 23:17     ` Gerd Stolpmann
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Le Fessant @ 2011-03-08 21:28 UTC (permalink / raw)
  To: caml-list

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

You can also define a printer for the exception Unix_error, once and for
all.

let _ =
  Printexc.register_printer (fun exn ->
    match exn with
      Unix.Unix_error (error, s1, s2) ->
        Some (Printf.sprintf "Unix_error(%s, %s, %s)"
(Unix.error_message error) s1 s2)
    | _ -> None)
;;

It would probably be a good idea to include this code directly in the
Unix module of the distribution, no ?
--Fabrice

On 03/08/2011 03:36 PM, Gerd Stolpmann wrote:
> Am Dienstag, den 08.03.2011, 13:17 +1100 schrieb Arlen Cuss:
> 
>> Exception Unix.Unix_error(31, "write", "") occurred
>> Exception Unix.Unix_error(56, "write", "") occurred
>>
>> Both are occurring with the same reported backtrace; the former is Unix
>> error EMLINK (too many links), the latter EISCONN (socket is connected);
>> the strange thing is that *neither* of these errors should be throwable
>> on a write() call!
> 
> That's not quite correct.
> 
> Error 31 is EPIPE. Error 56 is ECONNRESET. You can easily find out by
> typing in the toploop:
> 
> # (Obj.magic 31: Unix.error);;
> - : Unix.error = Unix.EPIPE
> # (Obj.magic 56: Unix.error);;
> - : Unix.error = Unix.ECONNRESET
> 
> The error numbers are not the official Unix ones, but something that
> ocaml uses internally.
> 
> Gerd
> 
> 
>>
>> I've ensured I'm correctly compiling with debug info, so I'm a bit lost.
>> I can only assume a sprintf or similar call somewhere is going haywire.
>>
>> Anyone seen anything like this before?
>>
>> Best,
>> Arlen
>>
>>
> 
> 

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 397 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;Projet OCamlPro
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


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

* Re: [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right.
  2011-03-08 21:28   ` Fabrice Le Fessant
@ 2011-03-08 23:17     ` Gerd Stolpmann
  0 siblings, 0 replies; 5+ messages in thread
From: Gerd Stolpmann @ 2011-03-08 23:17 UTC (permalink / raw)
  To: Fabrice Le Fessant; +Cc: caml-list

Am Dienstag, den 08.03.2011, 22:28 +0100 schrieb Fabrice Le Fessant:
> You can also define a printer for the exception Unix_error, once and for
> all.
> 
> let _ =
>   Printexc.register_printer (fun exn ->
>     match exn with
>       Unix.Unix_error (error, s1, s2) ->
>         Some (Printf.sprintf "Unix_error(%s, %s, %s)"
> (Unix.error_message error) s1 s2)
>     | _ -> None)
> ;;
> 
> It would probably be a good idea to include this code directly in the
> Unix module of the distribution, no ?

If it was not Unix.error_message but just the code (I rather like to
read "EPIPE" in log files and not a - possibly localized - error
message). Btw, such code is included in Ocamlnet.

Well, requirements differ.

Gerd


> --Fabrice
> 
> On 03/08/2011 03:36 PM, Gerd Stolpmann wrote:
> > Am Dienstag, den 08.03.2011, 13:17 +1100 schrieb Arlen Cuss:
> > 
> >> Exception Unix.Unix_error(31, "write", "") occurred
> >> Exception Unix.Unix_error(56, "write", "") occurred
> >>
> >> Both are occurring with the same reported backtrace; the former is Unix
> >> error EMLINK (too many links), the latter EISCONN (socket is connected);
> >> the strange thing is that *neither* of these errors should be throwable
> >> on a write() call!
> > 
> > That's not quite correct.
> > 
> > Error 31 is EPIPE. Error 56 is ECONNRESET. You can easily find out by
> > typing in the toploop:
> > 
> > # (Obj.magic 31: Unix.error);;
> > - : Unix.error = Unix.EPIPE
> > # (Obj.magic 56: Unix.error);;
> > - : Unix.error = Unix.ECONNRESET
> > 
> > The error numbers are not the official Unix ones, but something that
> > ocaml uses internally.
> > 
> > Gerd
> > 
> > 
> >>
> >> I've ensured I'm correctly compiling with debug info, so I'm a bit lost.
> >> I can only assume a sprintf or similar call somewhere is going haywire.
> >>
> >> Anyone seen anything like this before?
> >>
> >> Best,
> >> Arlen
> >>
> >>
> > 
> > 
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


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

end of thread, other threads:[~2011-03-08 23:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08  2:17 [Caml-list] Unix.Unix_error(31, "write", "") raised from format.ml!? This is not right Arlen Cuss
2011-03-08  2:22 ` Arlen Cuss
2011-03-08 14:35 ` Gerd Stolpmann
     [not found] ` <1001695803.480327.1299594992792.JavaMail.root@zmbs4.inria.fr>
2011-03-08 21:28   ` Fabrice Le Fessant
2011-03-08 23:17     ` Gerd Stolpmann

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