Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] ocamlc Stack_overflow

4 views
Skip to first unread message

Denis Bueno

unread,
Aug 8, 2006, 10:03:40 PM8/8/06
to OCaml Mailing List
[I tried sending this a few days ago with a rather large attachment.
Since it hasn't been approved since then, I'm sending it again, sans
attachment.]

All--

The source file available on my website [2] gives the following output
(when uncompressed, of course):

,----
| $ ocamlc -g -c spit_etest.ml
| Fatal error: exception Stack_overflow
`----

I really have no idea where to start, whether it's my fault or
ocamlc's. I have included some relevant system information [1].

Could someone point my in the right direction?

-Denis

[1]
,----
| $ uname -a
| Darwin ford.local 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26
15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh
powerpc
`----

,----
| $ ocamlc -version
| 3.09.2
`----

The ocaml I'm using was installed by Fink; the fink version (as
reported by `fink list ocaml` is 3.09.2-1000.

[2]
http://churn.ath.cx/spit_etest.ml.tar.bz2

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Martin Jambon

unread,
Aug 9, 2006, 12:22:45 AM8/9/06
to Denis Bueno
On Tue, 8 Aug 2006, Denis Bueno wrote:

> [I tried sending this a few days ago with a rather large attachment.
> Since it hasn't been approved since then, I'm sending it again, sans
> attachment.]
>
> All--
>
> The source file available on my website [2] gives the following output
> (when uncompressed, of course):
>
> ,----
> | $ ocamlc -g -c spit_etest.ml
> | Fatal error: exception Stack_overflow
> `----
>
> I really have no idea where to start, whether it's my fault or
> ocamlc's. I have included some relevant system information [1].
>
> Could someone point my in the right direction?

You are using a huge list, and it is likely that the compiler uses some
functions which will use stack space proportionally to the size of your list.
You can use one of the following options:
- use ocamlc.opt instead of ocamlc
- increase the maximum size of the stack:
env OCAMLRUNPARAM=l=10M ocamlc -c spit_etest.ml
- store your data externally

Note that your program itself might have the same problem at runtime if
you use non-tail-call optimized functions like List.map (see
documentation for module List).


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr

Jon Harrop

unread,
Aug 9, 2006, 8:01:47 AM8/9/06
to caml...@yquem.inria.fr
On Wednesday 09 August 2006 03:00, Denis Bueno wrote:
> | $ ocamlc -g -c spit_etest.ml
> | Fatal error: exception Stack_overflow
>
> `----
>
> I really have no idea where to start, whether it's my fault or
> ocamlc's. I have included some relevant system information [1].
>
> Could someone point my in the right direction?

The OCaml compilers aren't entirely tail recursive so they sometimes overflow
the stack on large input (especially autogenerated code). Easiest fixes:

1. Use ocamlc.opt because native code gets a bigger stack.
2. Use a bigger bytecode stack, set via the environment variable CAMLRUNPARAM.

You can also get stack overflows by compiling with -rectypes and linking
without it. I assume the type checker goes into infinite non-tail
recursion...

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists

Denis Bueno

unread,
Aug 9, 2006, 9:46:32 AM8/9/06
to OCaml Mailing List
Martin Jambon wrote:
> You are using a huge list, and it is likely that the compiler uses some
> functions which will use stack space proportionally to the size of your
> list.
> You can use one of the following options:
> - use ocamlc.opt instead of ocamlc
> - increase the maximum size of the stack:
> env OCAMLRUNPARAM=l=10M ocamlc -c spit_etest.ml

To anyone who may be interested: both of these methods worked for me.

-Denis

0 new messages