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

a Dynlink trap... #8071

Closed
vicuna opened this issue Mar 18, 2003 · 2 comments
Closed

a Dynlink trap... #8071

vicuna opened this issue Mar 18, 2003 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 18, 2003

Original bug ID: 1602
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: chris quinn
Version: 3.06
OS: linux
Submission from: 212.42.169.63 (212.42.169.63)

if a module Y to be loaded depends on the module X doing the loading
(init,loadfile),
there is a complaint:
"error while linking y.cmo.
The module `X' is not yet initialized"

which seems curious given that X is up and running.
before i found that making Y independent of X did the trick i
tried loadfile "x.cmo" before the load of y, and this resulted in a segfault.

about the path argument to [add_interfaces]: it had to include the standard
library path, and i thought of using Config.standard_library but unfortunately
this is internal to the compiler. if there is not something else i can use,
would it not be useful to make at least some of the ocaml configuration
available to the programming environment?

thanks

  • chris

x.ml-----------
class k = object
method init : unit = assert false
end

let reg = ref (new k)

let _ =
try
Dynlink.init();
Dynlink.add_interfaces
["X";"Dynlink";"Digest";"Y";"CamlinternalOO";"Pervasives"]
["";"/home/cq/programming/projects/SA-MetaTool/lib/ocaml"];
Dynlink.loadfile "y.cmo";
!reg#init;
with
| Dynlink.Error z -> print_endline("ERROR: "^Dynlink.error_message z)

y.ml--------------

class k = object
method init : unit = print_endline "Y registered"
end

let _ =
X.reg:= new k


ocamlc -c x.ml
ocamlc -c y.ml
ocamlc -o test dynlink.cma x.cmo

@vicuna
Copy link
Author

vicuna commented Mar 20, 2003

Comment author: administrator

if a module Y to be loaded depends on the module X doing the loading
(init,loadfile),
there is a complaint:
"error while linking y.cmo.
The module `X' is not yet initialized"
which seems curious given that X is up and running.

... but not yet fully initialized: a module is not fully initialized
until all its initialization code (the "let _ = ... " part of your example)
has completed.

before i found that making Y independent of X did the trick i tried
loadfile "x.cmo" before the load of y, and this resulted in a
segfault.

This should fail more cleanly :-) I'll see what I can do about it.

about the path argument to [add_interfaces]: it had to include the
standard library path, and i thought of using
Config.standard_library but unfortunately this is internal to the
compiler. if there is not something else i can use, would it not be
useful to make at least some of the ocaml configuration available to
the programming environment?

In the long run, probably yes. But the Dynlink.add_interfaces API
is poorly designed. In the working sources, new functions were added
to Dynlink to make it unnecessary to load interfaces from .cmi files.
(These can now be found in the running executable itself.)

Best regards,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented May 26, 2003

Comment author: administrator

The "not yet initialized" behavior is normal.
The reported segfault was fixed 2003-05-26 by XL.

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