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

Cyclic module aliases can crash the compiler #7694

Closed
vicuna opened this issue Dec 21, 2017 · 5 comments
Closed

Cyclic module aliases can crash the compiler #7694

vicuna opened this issue Dec 21, 2017 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Dec 21, 2017

Original bug ID: 7694
Reporter: @let-def
Status: new
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.0
Category: typing
Monitored by: @gasche

Bug description

When there is a cycle between module aliases, some function enter infinite loops and crash the compiler.

Steps to reproduce

$ cat > a.ml
module B = B
$ cat > b.ml
module A = A
$ ocamlc -c -no-alias-deps a.ml b.ml
$ cat > test.ml
module T : module type of A = struct end
$ ocamlc -c test.ml
Fatal error: exception Stack overflow

Additional information

This problem was first reported in Merlin, which misbehaved when using the the clarity library (https://github.com/IndiscriminateCoding/clarity) together with short-paths.

Clarity has this cyclic shape where Clarity = Clarity.Clarity

@vicuna
Copy link
Author

vicuna commented Dec 21, 2017

Comment author: @lpw25

This particular example is due to the "unfold all module aliases" behaviour of [module type of] (a similar thing would happen with [with module M =]). This behaviour causes a lot of other problems as well, and I'm hoping to get rid of it for 4.07.

Of course, there might be other parts of the type-checker where this causes problems.

@vicuna vicuna added the typing label Mar 14, 2019
@nojb
Copy link
Contributor

nojb commented Mar 17, 2019

Cannot reproduce in 4.07, so I'm assuming it has been fixed. @lpw25 ?

@lpw25
Copy link
Contributor

lpw25 commented Mar 17, 2019

That example was fixed by the change in behaviour of module type of in #1652. However, I expect that the general pattern of using -no-alias-deps to make recursive module aliases probably still causes problems elsewhere in the compiler so maybe leave this open.

@github-actions
Copy link

github-actions bot commented May 7, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 7, 2020
@lpw25
Copy link
Contributor

lpw25 commented May 7, 2020

Let's close this until someone hits another reproduction case

@lpw25 lpw25 closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants