Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] "dangling" exception in native code.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Artem Prisyznuk <temofey@g...>
Subject: [Caml-list] "dangling" exception in native code.
Hello,

Next small example produce segfault for native code, but work ok in byte
code.

I use OCaml 3.06. I compile and run this example on Linux, Win98, and Cygwin
systems, result is same.


type s = { mutable exc : exn };;
        
let run max = begin
    let rec loop n acc = 
      if n > 0
      then
        let s = { exc = Not_found } in
        let f () =
          s.exc <- Failure (string_of_int n);
          raise Not_found
        in
        loop ( n - 1 ) ( (s, f) :: acc )
      else acc in
    print_endline "Make list"; flush_all ();
    let lst = loop max [] in
    print_endline "Iter 1"; flush_all ();
    List.iter 
      (fun (s,f) -> try f () with Not_found -> ()  ) 
      lst;
    print_endline "Iter 2"; flush_all ();
    List.iter 
      (fun (s,_) -> ignore(Printexc.to_string s.exc) ) 
      lst;
    print_endline "The End"; flush_all ()
    end;;
        
let _ = run 3000 ;;


-- 
Best Regards,
Artem Prisyanuk
tema@sit.kiev.ua
-------------------
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