Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Troubles with marshaled/unmarshaled exception
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Troubles with marshaled/unmarshaled exception
Eric C. Cooper wrote:
> On Thu, Dec 04, 2003 at 07:11:51PM +0100, Alex Baretta wrote:

> But something is indeed broken.  Here's a slight variant of the above:
> 
>         Objective Caml version 3.07+2
> 
> # let e = Failure "test";;
> val e : exn = Failure "test"
> # let e' = Failure "test";;
> val e' : exn = Failure "test"
> # let e'' =  Marshal.from_string (Marshal.to_string e []) 0;;
> val e'' : 'a = <poly>
> # e'' ^ "good-bye";;
> Segmentation fault
> 

There's nothing wrong here. Module Marshal is not type safe. If you use 
it incorrectly you cannot complain if your program segfaults. The value 
represented by e'' actually has type exn, however the compiler cannot 
know this because you are defining it through Marshal.from_xxxx, which 
is not type safe. This allows you to type-check e'' ^ "good-bye" which 
segfaults.

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