Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003214OCamlOCaml generalpublic2004-10-14 00:022008-01-22 12:03
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version3.10+dev 
Summary0003214: Exception printing bug?
DescriptionHi,

there seems to be a bug printing exceptions. First of all, the
implementations of the module Printexc and of byterun/printexc.c don't
match. E.g.:

---------------------------------------------------------------------------
exception E of (int * string)

let () =
  let exc = E (42, "bla") in
  print_endline (Printexc.to_string exc);
  raise exc
---------------------------------------------------------------------------

As can be seen the C-function does a better job printing the escaping
exception.

In addition to this we have also complicated applications that sometimes
print out exceptions containing only one string argument without the
contents of the string, e.g.:

  exception SomeException of string

Leads to the exception string:

  SomeException (_)

instead of:

  SomeException ("explanation of error")

I haven't yet managed to reproduce this error reliably. Maybe you have
an idea why this can happen?

Best regards,
Markus

--
Markus Mottl http://www.oefai.at/~markus [^] markus@oefai.at

TagsNo tags attached.
Attached Files

- Relationships
related to 0004476closeddoligez Another exception printing bug 

-  Notes
(0003089)
administrator (administrator)
2004-11-18 10:19

> there seems to be a bug printing exceptions. First of all, the
> implementations of the module Printexc and of byterun/printexc.c don't
> match. E.g.:
> exception E of (int * string)
> [...]

Right, exceptions that take a tuple of arguments are special-cased
differently in Printexc and in the runtime system. Note however that
the code in the runtime system sometimes goes too far, e.g.

    exception E of string list
    let () = raise (E ["foo"])

prints

    Fatal error: exception Foo.E("foo", 0)

so it's unclear we want to reproduce this bug in Printexc...

Also, "exception E of int * string" would work fine in both printers.

> In addition to this we have also complicated applications that sometimes
> print out exceptions containing only one string argument without the
> contents of the string, e.g.:
>
> exception SomeException of string
>
> Leads to the exception string:
>
> SomeException (_)
>
> instead of:
>
> SomeException ("explanation of error")
>
> I haven't yet managed to reproduce this error reliably. Maybe you have
> an idea why this can happen?

How is the printing done? At the toplevel, via Printexc or by the
runtime system? The only case that I know of is at the toplevel:

  # exception E of string list;;
  exception E of string list
  # let f () = raise (E ["hello"]);;
  val f : unit -> 'a = <fun>
  # exception E of int;;
  exception E of int
  # f ();;
  Exception: E _.

It's due to the shadowing of the declaration of E. But even in this
case, exceptions that carry a string are special-cased and print
correctly:

  # exception E of string;;
  exception E of string
  # let f () = raise (E "hello");;
  val f : unit -> 'a = <fun>
  # exception E of int;;
  exception E of int
  # f ();;
  Exception: E "hello".

Best wishes,

- Xavier Leroy

(0003090)
administrator (administrator)
2004-11-22 21:09

On Thu, 18 Nov 2004, Xavier Leroy wrote:
> > In addition to this we have also complicated applications that sometimes
> > print out exceptions containing only one string argument without the
> > contents of the string, e.g.:
> >
> > exception SomeException of string
> >
> > Leads to the exception string:
> >
> > SomeException (_)
> >
> > instead of:
> >
> > SomeException ("explanation of error")
> >
> > I haven't yet managed to reproduce this error reliably. Maybe you have
> > an idea why this can happen?
>
> How is the printing done? At the toplevel, via Printexc or by the
> runtime system? The only case that I know of is at the toplevel:
[snip]
> It's due to the shadowing of the declaration of E. But even in this
> case, exceptions that carry a string are special-cased and print
> correctly:
[snip]

It's actually also Failure-exceptions which are sometimes printed
without argument. It happens very rarely, I hope we will be able to
reliably reproduce this problem in a short code snippet. Thanks anyway
for investigating this.

Best regards,
Markus

(0003091)
administrator (administrator)
2005-01-31 17:28

Waiting for repro case.
(0004412)
gerd (reporter)
2008-01-11 16:33

I don't have a repro case for Failure, but for Invalid_argument. Separately reported as 0004476.
(0004424)
doligez (administrator)
2008-01-22 12:03

fixed in 3.10.2+dev2

- Issue History
Date Modified Username Field Change
2005-11-18 10:14 administrator New Issue
2008-01-11 16:33 gerd Note Added: 0004412
2008-01-17 17:08 doligez Relationship added related to 0004476
2008-01-22 12:03 doligez Note Added: 0004424
2008-01-22 12:03 doligez Status acknowledged => closed
2008-01-22 12:03 doligez Resolution unable to reproduce => fixed
2008-01-22 12:03 doligez Fixed in Version => 3.10+dev
2008-01-22 12:03 doligez Description Updated


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker