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

toplevel/toploop.mli fragile #2764

Closed
vicuna opened this issue May 14, 2001 · 2 comments
Closed

toplevel/toploop.mli fragile #2764

vicuna opened this issue May 14, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented May 14, 2001

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

Bug description

Full_Name: Cristiano Calcagno
Version: ocaml 3.01
OS: Sparc 7 & Linux/x86
Submission from: pc201.dcs.qmw.ac.uk (138.37.88.84)

Adding any function at the BEGINNING of toplevel/toploop.mli makes the top loop
unstable.
E.G.
adding to toplevel/toploop.mli the following after "open Format"
val somefun : unit -> unit
and the foollowing anywhere in toplevel/toploop.ml
let somefun () = ()
then the following toplevel session
# let a = 4;;
>> Fatal error: a unbound at toplevel
Uncaught exception: Misc.Fatal_error.
With other changes to toploop.mli I got core dumps.
If instead somefun is added at the END, all works.
The behaviour is consistent under Sparc and Linux/x86.
The problem does not appear in ocaml 3.00.

@vicuna
Copy link
Author

vicuna commented May 14, 2001

Comment author: administrator

Hi Cristiano,

Adding any function at the BEGINNING of toplevel/toploop.mli makes
the top loop unstable.

Correct. This is even "documented" in a comment in toploop.mli:

(* Accessors for the table of toplevel value bindings. These functions
must appear as first and second exported functions in this module.
(See module Translmod.) *)
val getvalue : string -> Obj.t
val setvalue : string -> Obj.t -> unit

The reason is that the code generated for toplevel phrases assume that
"getvalue" is the first field of the tuple representing the Toplevel
module, and "setvalue" is the second one. Yes, it's not pretty, but
that's the kind of meta-level trickery that you can expect from a
toplevel interactive loop...

The problem does not appear in ocaml 3.00.

Right, the handling of toplevel bindings was changed in 3.01 to play
nicer with the GC.

Cheers,

  • Xavier

@vicuna
Copy link
Author

vicuna commented May 14, 2001

Comment author: administrator

It's a documented bug :-)

@vicuna vicuna closed this as completed May 14, 2001
@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