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

ocamlopt crashes with "Fatal error: exception Stack_overflow" #6364

Closed
vicuna opened this issue Apr 8, 2014 · 3 comments
Closed

ocamlopt crashes with "Fatal error: exception Stack_overflow" #6364

vicuna opened this issue Apr 8, 2014 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Apr 8, 2014

Original bug ID: 6364
Reporter: kerneis
Status: resolved (set by @xavierleroy on 2014-06-05T14:30:57Z)
Resolution: suspended
Priority: normal
Severity: crash
Version: 4.01.0
Category: back end (clambda to assembly)
Related to: #5626 #5925

Bug description

The following file (too large to be hosted on Mantis) is a 5.4MB .ml file generated automatically:

https://gist.githubusercontent.com/kerneis/9af54c536d5e07b9e2c8/raw/0c5ee22ea5d37143d56116977eccdd2d133f64a7/gistfile1.ml

It consists of a few type definitions for an AST, and then a single, huge term (let defs starting on line 448). It is probably pathological, but here is what happens when I try and compile it anyway:

$ ocamlc.opt -c -o power.cmo gistfile1.ml
$ ocamlopt -c -o power.cmx gistfile1.ml
Fatal error: exception Stack_overflow

I get the same results with ocamlc.opt and ocamlopt.opt.

I'm not sure it's worth spending too many efforts fixing, but I figured it might help uncover some bug in ocamlopt.

File attachments

@vicuna
Copy link
Author

vicuna commented Apr 8, 2014

Comment author: kerneis

Attached compressed test file.

@vicuna
Copy link
Author

vicuna commented Apr 8, 2014

Comment author: @yallop

The culprit seems to be non-tail recursion in the backend, in particular Compilenv.structured_constants, which uses List.map (and so could be easily fixed), and Comballoc.combine, which requires a bit more work.

In the meantime, you may be able to work around the issue with something like 'ulimit'. The following works for me:

$ ulimit -s 65536
$ ocamlopt.opt -c gistfile1.ml

@vicuna
Copy link
Author

vicuna commented Jun 5, 2014

Comment author: @xavierleroy

I am marking this PR as "suspended" for the reasons given in #5925, namely: making the native-code generator tail-recursive is a very invasive change, and supporting huge generated source files is a low priority.

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

1 participant