You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1640 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Hans Ole Rafaelsen
Version: 3.06
OS: linux
Submission from: itherther.simula.no (129.240.228.187)
Hello,
seems to be some strange problem when Dynlink.init() is called
multiple times. If the code being loaded contains floating point
operations the program will crash with segmentation fault. This
happens both if the floating point operations get executed during load
time, or if they are within a function which register a handle. In
the later case, it will crash once the loaded function get called.
Code operating on integers or strings does not seems to have this
problem.
The quick fix is to only call Dynlink.init() once :-), but the
behavior when it is called multiple times is so strange that I decided
to fill a bug report on this.
Kindest regards,
Hans Ole Rafaelsen
foo.ml---------------
let bar_ref = ref (fun () -> ())
let set_bar f =
bar_ref := f
let do_bar () =
!bar_ref ()
bar.ml---------------
(* The function )
let f () =
( let _ = ("dd" ^ "aa") in )
( let _ = 2 + 4 in )
let _ = 2.0 +. 1.0 in ( Will make the loaded code crash *)
()
(* Register it when loaded )
let _ =
( let _ = 2.0 +. 1.0 in *)
Foo.set_bar f
main.ml--------------
let _ = Dynlink.init()
let _ = Dynlink.init() (* Needed to get the loaded code to crash *)
let loadit() =
try
let _ =
Dynlink.add_interfaces ["Foo"; "Pervasives"] ["/work/hans/lib/ocaml/";
"/hom/hans/QUA/tmp/bug/"] in
Dynlink.loadfile "bar.cmo"
with Dynlink.Error e ->
Printf.printf "Dynlink error : %s " (Dynlink.error_message e)
Original bug ID: 1640
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Hans Ole Rafaelsen
Version: 3.06
OS: linux
Submission from: itherther.simula.no (129.240.228.187)
Hello,
seems to be some strange problem when Dynlink.init() is called
multiple times. If the code being loaded contains floating point
operations the program will crash with segmentation fault. This
happens both if the floating point operations get executed during load
time, or if they are within a function which register a handle. In
the later case, it will crash once the loaded function get called.
Code operating on integers or strings does not seems to have this
problem.
The quick fix is to only call Dynlink.init() once :-), but the
behavior when it is called multiple times is so strange that I decided
to fill a bug report on this.
Kindest regards,
Hans Ole Rafaelsen
foo.ml---------------
let bar_ref = ref (fun () -> ())
let set_bar f =
bar_ref := f
let do_bar () =
!bar_ref ()
bar.ml---------------
(* The function )
let f () =
( let _ = ("dd" ^ "aa") in )
( let _ = 2 + 4 in )
let _ = 2.0 +. 1.0 in ( Will make the loaded code crash *)
()
(* Register it when loaded )
let _ =
( let _ = 2.0 +. 1.0 in *)
Foo.set_bar f
main.ml--------------
let _ = Dynlink.init()
let _ = Dynlink.init() (* Needed to get the loaded code to crash *)
let loadit() =
try
let _ =
Dynlink.add_interfaces ["Foo"; "Pervasives"] ["/work/hans/lib/ocaml/";
"/hom/hans/QUA/tmp/bug/"] in
Dynlink.loadfile "bar.cmo"
with Dynlink.Error e ->
Printf.printf "Dynlink error : %s " (Dynlink.error_message e)
let _ = loadit()
(* Test it *)
let _ = Foo.do_bar ()
ocamlc -c foo.ml
ocamlc -c bar.ml
ocamlc foo.cmo dynlink.cma main.ml
./a.out
The text was updated successfully, but these errors were encountered: