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

ocamlc diverges #3192

Closed
vicuna opened this issue Feb 7, 2002 · 3 comments
Closed

ocamlc diverges #3192

vicuna opened this issue Feb 7, 2002 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 7, 2002

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

Bug description

Full_Name: Claudio Sacerdoti Coen
Version: 3.04
OS: Linux debian stable
Submission from: a-bo44-24.tin.it (213.45.192.23)

Retrieve http://www.cs.unibo.it/~sacerdot/divergence.tgz.
You will find:

  1. a Makefile
  2. a bunch of .mli files
  3. a single .ml file

make will compile all the .mli files; then ocamlc will try to make the .cmo and
it will diverge (or at least require hundreds of megabytes of RAM)

Notes:

  1. the .ml file is minimal. I have not tried to get a minimal bunch of .mli
    files
  2. The bug seems to be related to recursive functions, the "let module"
    construct
    and mutual recursive classes.
  3. Replacing the commented line in the .ml with the uncommented one the bug is
    avoided. The line just replaces G.element_of_node with
    Gdome.element_of_node
    where G is bound by "let module G = Gdome in"
@vicuna
Copy link
Author

vicuna commented Feb 14, 2002

Comment author: administrator

From: sacerdot@cs.unibo.it

make will compile all the .mli files; then ocamlc will try to make
the .cmo and it will diverge (or at least require hundreds of
megabytes of RAM)

After looking desesparately for a bug, I have now the feeling that
this is just a complexity problem.
In particular, compilation terminates if you comment out method
[get_ownerDocument], line 347 of gdome.mli, which is the only reference
to [document] accessible from [element]. This greatly reduces the
accessible type graph, and is enough for the algorithm to terminate.

Why such a strange behaviour? Since module G is defined locally, all
references to it must disappear inside exported types. Since (element
: Gdome.element) is declared outside of the let module scope, applying
[aux] to [element] forces to eliminate all references to [G] in
[G.element_of_node]. Unfortunately, [G.element_of_node] does not
expand to [Gnome.element_of_node] but to its full object type. In turn
all types referencing G inside it must be expanded... Recursion is
handled, but this is still highly exponential, as your examples
exhibits.

If I'm not wrong, we will have to do something about that.

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented May 7, 2002

Comment author: administrator

The divergence problem due to mutually recursive definitions in
a locally opened module is now solved.

Note that the fix is only partial, and is just a side-effect on an optimization
caching expansions of types with no parameters. You can generate the same
problem by having mutual recursion between type abbreviations with parameters,
or using the -principal switch, which disables the caching :-(

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented May 7, 2002

Comment author: administrator

Partially solved by caching of expansions.

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