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

Multiple Dynlink.init() makes loaded floating point code seg. fault #8106

Closed
vicuna opened this issue Apr 15, 2003 · 1 comment
Closed

Multiple Dynlink.init() makes loaded floating point code seg. fault #8106

vicuna opened this issue Apr 15, 2003 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 15, 2003

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

@vicuna
Copy link
Author

vicuna commented May 26, 2003

Comment author: administrator

Same bug, same fix as #8071. Fixed 2003-05-26 by XL.

@vicuna vicuna closed this as completed May 26, 2003
@vicuna vicuna added the bug label Mar 19, 2019
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