Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception printing bug? #3214

Closed
vicuna opened this issue Oct 13, 2004 · 5 comments
Closed

Exception printing bug? #3214

vicuna opened this issue Oct 13, 2004 · 5 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 13, 2004

Original bug ID: 3214
Reporter: administrator
Status: closed (set by @damiendoligez on 2008-01-22T11:03:20Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 3.10+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #4476

Bug description

Hi,

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

@vicuna
Copy link
Author

vicuna commented Nov 18, 2004

Comment author: administrator

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 =

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 =

exception E of int;;

exception E of int

f ();;

Exception: E "hello".

Best wishes,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Nov 22, 2004

Comment author: administrator

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

@vicuna
Copy link
Author

vicuna commented Jan 31, 2005

Comment author: administrator

Waiting for repro case.

@vicuna
Copy link
Author

vicuna commented Jan 11, 2008

Comment author: gerd

I don't have a repro case for Failure, but for Invalid_argument. Separately reported as #4476.

@vicuna
Copy link
Author

vicuna commented Jan 22, 2008

Comment author: @damiendoligez

fixed in 3.10.2+dev2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant