<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/3e970e2f840009aa76fa39ca1546430a"
  from="Artem Prisyznuk &lt;temofey@g...&gt;"
  author="Artem Prisyznuk"
  date="2002-12-23T10:35:05"
  subject="[Caml-list] &quot;dangling&quot; exception in native code."
  prev="2002/12/2f5b617341ef2775e317b43c43098b58"
  next="2002/12/92beeff2aa9449d9d9619da5b4f29b2d"
  prev-thread="2002/12/c7b4e0ea2cd45574dbf17ca1f5b4f7b4"
  next-thread="2002/12/0a83de82e890459a006d9ed53576a8c9"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] &quot;dangling&quot; exception in native code.">
<msg 
  url="2002/12/3e970e2f840009aa76fa39ca1546430a"
  from="Artem Prisyznuk &lt;temofey@g...&gt;"
  author="Artem Prisyznuk"
  date="2002-12-23T10:35:05"
  subject="[Caml-list] &quot;dangling&quot; exception in native code.">
</msg>
</thread>

<contents>
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 &gt; 0
      then
        let s = { exc = Not_found } in
        let f () =
          s.exc &lt;- 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) -&gt; try f () with Not_found -&gt; ()  ) 
      lst;
    print_endline "Iter 2"; flush_all ();
    List.iter 
      (fun (s,_) -&gt; 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

</contents>

</message>

