caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] Uncaught exceptions (or am I going crazy?)
@ 2002-10-03  0:46 Arturo Borquez
  0 siblings, 0 replies; 9+ messages in thread
From: Arturo Borquez @ 2002-10-03  0:46 UTC (permalink / raw)
  To: "Yaron M. Minsky"; +Cc: caml-list

"Yaron M. Minsky" <yminsky@CS.Cornell.EDU> wrote:

>I'm getting some very weird behavior with respect to exception handling 
>in ocaml 3.06.  I'm probably missing something obvious, but here's my 
>situation.  I have a networking application which for some reason, 
>occasionally prints out the following message:
>
>Uncaught exception: Sys_error("Broken pipe")
>
>What's so strange about this is that as far as I can tell, there is no 
>place in my code where I actually print out such errors.  In particular, 
>the text "Uncaught exception" doesn't appear anywhere in my code, and I 
>don't see any printfs that could be the cause either.  And weirdly, this 
>only seems to come up with byte-code compiled code.
>
>So has anyone else seen something like this?
>
>y

It is a standard message derived from an unhandled exception in your
program. The text clearly displays "Uncaugth exception" because of a
broken pipe in this case. This is a normal behaivor for all unhandled
exceptions. See the section of 'exceptions' in the manual.

Regards

-- 
Arturo Borquez


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
       [not found]             ` <15771.6812.266404.848081@paille.inria.fr>
@ 2002-10-02 16:19               ` Yaron M. Minsky
  0 siblings, 0 replies; 9+ messages in thread
From: Yaron M. Minsky @ 2002-10-02 16:19 UTC (permalink / raw)
  To: tom.hirschowitz, Ocaml List

That's it!  Thanks.

y


Tom Hirschowitz wrote:
>>From module Printexc (stdlib):
> 
> let print fct arg =
>   try
>     fct arg
>   with x ->
>     eprintf "Uncaught exception: %s\n" (to_string x);
>     flush stderr;
>     raise x
> 
> let catch fct arg =
>   try
>     fct arg
>   with x ->
>     flush stdout;
>     eprintf "Uncaught exception: %s\n" (to_string x);
>     exit 2
> 
> So maybe one of your libs uses this.
> 
> Yaron M. Minsky writes:
>  > I'm not sure what you mean.  I catch and handle lots of exceptions in my 
>  > code.  But nowhere do I have the text "Uncaught exception".  I can't 
>  > figure out where that text is coming from.
>  > 
>  > y
>  > 
>  > Tom Hirschowitz wrote:
>  > > Probably you could as well look for code catching
>  > > any exception, not especially Sys_errors, right?
>  > > 
>  > >  > code.  It doesn't seem like any of those should be catching Sys_errors.
>  > 
>  > 
>  > 
>  > 



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
  2002-10-02 15:38   ` Yaron M. Minsky
@ 2002-10-02 16:04     ` Alessandro Baretta
  2002-10-02 15:57       ` Yaron M. Minsky
  0 siblings, 1 reply; 9+ messages in thread
From: Alessandro Baretta @ 2002-10-02 16:04 UTC (permalink / raw)
  To: Yaron M. Minsky, Ocaml



Yaron M. Minsky wrote:
> All the explanations given so far make sense except for one thing:  they 
> all suggest that the program should terminate.  But my program doesn't 
> terminate, it just prints out the "Uncaught exception" string and keeps 
> on executing.  I am not to my knowledge making any use of threads, so 
> that odesn't seem like it should be the right explanation either.
> 
> So, any more thoughts?
> 
> y

I noticed this. You are probably linking to a library which 
raises and then catches the exception, printing out the 
error message. Oftentimes, GUI libraries have this feature. 
This might explain why your program does not terminate when 
the exception is raised.

Can you send in a test case that reproduces this behavior, 
for reference?

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
  2002-10-02 16:04     ` Alessandro Baretta
@ 2002-10-02 15:57       ` Yaron M. Minsky
       [not found]         ` <15771.6363.899204.33252@paille.inria.fr>
  0 siblings, 1 reply; 9+ messages in thread
From: Yaron M. Minsky @ 2002-10-02 15:57 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

Alessandro Baretta wrote:
> 
> 
> Yaron M. Minsky wrote:
> 
>> All the explanations given so far make sense except for one thing:  
>> they all suggest that the program should terminate.  But my program 
>> doesn't terminate, it just prints out the "Uncaught exception" string 
>> and keeps on executing.  I am not to my knowledge making any use of 
>> threads, so that odesn't seem like it should be the right explanation 
>> either.
>>
>> So, any more thoughts?
>>
>> y
> 
> 
> I noticed this. You are probably linking to a library which raises and 
> then catches the exception, printing out the error message. Oftentimes, 
> GUI libraries have this feature. This might explain why your program 
> does not terminate when the exception is raised.
> 
> Can you send in a test case that reproduces this behavior, for reference?
> 
> Alex

Unfortunately, I don't have a nice, small test case as of yet.  I'll 
send one in when I get it.  As for libraries, I'm using numerix, 
cryptokit, bigarray, unix and str.  I think that's it except for my own 
code.  It doesn't seem like any of those should be catching Sys_errors.

y

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
       [not found] ` <3D9B0978.E4A5D96@beaune.inria.fr>
@ 2002-10-02 15:38   ` Yaron M. Minsky
  2002-10-02 16:04     ` Alessandro Baretta
  0 siblings, 1 reply; 9+ messages in thread
From: Yaron M. Minsky @ 2002-10-02 15:38 UTC (permalink / raw)
  To: Ocaml List

All the explanations given so far make sense except for one thing:  they 
all suggest that the program should terminate.  But my program doesn't 
terminate, it just prints out the "Uncaught exception" string and keeps 
on executing.  I am not to my knowledge making any use of threads, so 
that odesn't seem like it should be the right explanation either.

So, any more thoughts?

y

Didier Le Botlan wrote:
> ( << J'ai ! >> )
> 
> Try this one :
> 
> let arr = Array.create 5 " a cell "
> let _ = print_string arr.(0) ; print_string arr.(10) ;;   
> 
> 
> I get << a cell Fatal error: exception Invalid_argument("Array.get") >>
> It's a feature ! Reading a cell outside an array raises an exception and
> prints it on the screen.
> Similarly, when a pipe is closed, a system exception is raised.
> Since you do not catch the exception with a 'try ... with Sys_error m ->
> ...' block, you get the message on stderr, that is on your screen.
> 
> Does it answer your question ?
> 
> 
> "Yaron M. Minsky" a écrit :
> 
>>I'm getting some very weird behavior ...
>>What's so strange about this is that as far as I can tell, there is no
>>place in my code where I actually print out such errors.
> 



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* RE: [Caml-list] Uncaught exceptions (or am I going crazy?)
  2002-10-02 14:34 Yaron M. Minsky
  2002-10-02 14:59 ` Didier Le Botlan
  2002-10-02 15:01 ` Maxence Guesdon
@ 2002-10-02 15:06 ` Michael Hicks
       [not found] ` <3D9B0978.E4A5D96@beaune.inria.fr>
  3 siblings, 0 replies; 9+ messages in thread
From: Michael Hicks @ 2002-10-02 15:06 UTC (permalink / raw)
  To: Yaron M. Minsky, Ocaml List

In Unix, if you don't create a signal handler that explicitly handles or
ignores the signal SIGPIPE, this signal will be thrown to the application if
its tries to write to a file descriptor that has been closed (in particular
if it has received an RST from the remote TCP host).  If the signal is dealt
with by the application, the offending write will return the error EPIPE.  I
presume that the OCaml implementation has manifested the throwing of the
signal by raising the exception you are seeing.

Hope this helps.
Mike

-----Original Message-----
From: owner-caml-list@pauillac.inria.fr
[mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of Yaron M. Minsky
Sent: Wednesday, October 02, 2002 10:34 AM
To: Ocaml List
Subject: [Caml-list] Uncaught exceptions (or am I going crazy?)


I'm getting some very weird behavior with respect to exception handling
in ocaml 3.06.  I'm probably missing something obvious, but here's my
situation.  I have a networking application which for some reason,
occasionally prints out the following message:

Uncaught exception: Sys_error("Broken pipe")

What's so strange about this is that as far as I can tell, there is no
place in my code where I actually print out such errors.  In particular,
the text "Uncaught exception" doesn't appear anywhere in my code, and I
don't see any printfs that could be the cause either.  And weirdly, this
only seems to come up with byte-code compiled code.

So has anyone else seen something like this?

y

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
  2002-10-02 14:34 Yaron M. Minsky
  2002-10-02 14:59 ` Didier Le Botlan
@ 2002-10-02 15:01 ` Maxence Guesdon
  2002-10-02 15:06 ` Michael Hicks
       [not found] ` <3D9B0978.E4A5D96@beaune.inria.fr>
  3 siblings, 0 replies; 9+ messages in thread
From: Maxence Guesdon @ 2002-10-02 15:01 UTC (permalink / raw)
  To: Yaron M. Minsky; +Cc: caml-list

Hi,

> ...
> Uncaught exception: Sys_error("Broken pipe")
> ...

This message is printed to indicate your program terminated because an exception was raised but not caught by any 
 try ... with ...  
clause. The program execution is then aborted, and a message is printed with a description of the exception.

I think, the exception Sys_error("broken pipe") can occur, for example, if you try to write to a socket which has been closed by the application on the other side of the pipe.

For more information on exceptions handling :
http://caml.inria.fr/oreilly-book/html/book-ora017.html

> So has anyone else seen something like this?

Sure, everybody on this list has, one day or another, encountered such a 'strange behaviour' (brrr......) :-)

-- 
Maxence Guesdon


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Uncaught exceptions (or am I going crazy?)
  2002-10-02 14:34 Yaron M. Minsky
@ 2002-10-02 14:59 ` Didier Le Botlan
  2002-10-02 15:01 ` Maxence Guesdon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Didier Le Botlan @ 2002-10-02 14:59 UTC (permalink / raw)
  To: Ocaml List

( << J'ai ! >> )

Try this one :

let arr = Array.create 5 " a cell "
let _ = print_string arr.(0) ; print_string arr.(10) ;;   


I get << a cell Fatal error: exception Invalid_argument("Array.get") >>
It's a feature ! Reading a cell outside an array raises an exception and
prints it on the screen.
Similarly, when a pipe is closed, a system exception is raised.
Since you do not catch the exception with a 'try ... with Sys_error m ->
...' block, you get the message on stderr, that is on your screen.

Does it answer your question ?


"Yaron M. Minsky" a écrit :
> 
> I'm getting some very weird behavior ...
> What's so strange about this is that as far as I can tell, there is no
> place in my code where I actually print out such errors.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Uncaught exceptions (or am I going crazy?)
@ 2002-10-02 14:34 Yaron M. Minsky
  2002-10-02 14:59 ` Didier Le Botlan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Yaron M. Minsky @ 2002-10-02 14:34 UTC (permalink / raw)
  To: Ocaml List

I'm getting some very weird behavior with respect to exception handling 
in ocaml 3.06.  I'm probably missing something obvious, but here's my 
situation.  I have a networking application which for some reason, 
occasionally prints out the following message:

Uncaught exception: Sys_error("Broken pipe")

What's so strange about this is that as far as I can tell, there is no 
place in my code where I actually print out such errors.  In particular, 
the text "Uncaught exception" doesn't appear anywhere in my code, and I 
don't see any printfs that could be the cause either.  And weirdly, this 
only seems to come up with byte-code compiled code.

So has anyone else seen something like this?

y

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-10-03  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-03  0:46 [Caml-list] Uncaught exceptions (or am I going crazy?) Arturo Borquez
  -- strict thread matches above, loose matches on Subject: below --
2002-10-02 14:34 Yaron M. Minsky
2002-10-02 14:59 ` Didier Le Botlan
2002-10-02 15:01 ` Maxence Guesdon
2002-10-02 15:06 ` Michael Hicks
     [not found] ` <3D9B0978.E4A5D96@beaune.inria.fr>
2002-10-02 15:38   ` Yaron M. Minsky
2002-10-02 16:04     ` Alessandro Baretta
2002-10-02 15:57       ` Yaron M. Minsky
     [not found]         ` <15771.6363.899204.33252@paille.inria.fr>
     [not found]           ` <3D9B198D.7020605@cs.cornell.edu>
     [not found]             ` <15771.6812.266404.848081@paille.inria.fr>
2002-10-02 16:19               ` Yaron M. Minsky

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