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, ocaml, ocamlc, Stack Overflow on large hardcoded arrays. #4405

Closed
vicuna opened this issue Sep 25, 2007 · 2 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link

commented Sep 25, 2007

Original bug ID: 4405
Reporter: vbigiani
Status: closed (set by @xavierleroy on 2007-11-06T15:27:06Z)
Resolution: not a bug
Priority: normal
Severity: crash
Version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)
Has duplicate: #6713
Related to: #5844 #5925
Monitored by: thelema vbigiani

Bug description

If a .ml file contains an array that is of large size, ocamlopt(.opt).exe, ocaml.exe and ocamlc.(opt).exe all crash with a Stack Overflow exception. It happens if the array has 274 896 elements, but not if it has 60 000 elements. If I split the array in smaller parts and then I call Array.concat to merge them into the original array, the resulting program will work correctly.

In the attachment, crash.ml has a single 274 896 arrays and will crash all the aforementioned programs, whereas no-crash.ml has splitted the array in five parts and doesn't crash (and, FWIW, can Array.iter and Array.get without trouble).

Additional information

Windows X86, OCaml 3.10.0 / MinGW.

File attachments

@vicuna

This comment has been minimized.

Copy link
Author

commented Nov 2, 2007

Comment author: thelema

Can't reproduce: Using mandriva build of ocaml 3.10.0, 'ocamlc crash.ml' produces a perfectly good a.out file, without crashing. This is on 32-bit linux x86.

@vicuna

This comment has been minimized.

Copy link
Author

commented Nov 6, 2007

Comment author: @xavierleroy

The compilers use stack space proportional to the size of the array expression. So, yes, you can get stack overflow conditions at compile-time. With the "non-opt" compilers ocamlc, ocamlopt, you can easily increase the stack space available to the compiler: set the OCAMLRUNPARAM environment variable to e.g.
"l=10M" (10 mega-words of stack space, instead of the default 1 mega-words).
Increasing the stack space for ocamlc.opt and ocamlopt.opt is OS-dependent and is not possible under Windows as far as I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.