caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlc Stack_overflow
@ 2006-08-04  1:03 Denis Bueno
  2006-08-09  2:00 ` Denis Bueno
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Bueno @ 2006-08-04  1:03 UTC (permalink / raw)
  To: OCaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

All--

The attached file 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.

[-- Attachment #2: spit_etest.ml.tar.gz --]
[-- Type: application/x-gzip, Size: 66078 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* ocamlc Stack_overflow
  2006-08-04  1:03 ocamlc Stack_overflow Denis Bueno
@ 2006-08-09  2:00 ` Denis Bueno
  2006-08-09  2:54   ` [Caml-list] " Jon Harrop
  2006-08-09  4:19   ` Martin Jambon
  0 siblings, 2 replies; 5+ messages in thread
From: Denis Bueno @ 2006-08-09  2:00 UTC (permalink / raw)
  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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] ocamlc Stack_overflow
  2006-08-09  2:00 ` Denis Bueno
@ 2006-08-09  2:54   ` Jon Harrop
  2006-08-09  4:19   ` Martin Jambon
  1 sibling, 0 replies; 5+ messages in thread
From: Jon Harrop @ 2006-08-09  2:54 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] ocamlc Stack_overflow
  2006-08-09  2:00 ` Denis Bueno
  2006-08-09  2:54   ` [Caml-list] " Jon Harrop
@ 2006-08-09  4:19   ` Martin Jambon
  2006-08-09 13:41     ` Denis Bueno
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Jambon @ 2006-08-09  4:19 UTC (permalink / raw)
  To: Denis Bueno; +Cc: OCaml Mailing List

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] ocamlc Stack_overflow
  2006-08-09  4:19   ` Martin Jambon
@ 2006-08-09 13:41     ` Denis Bueno
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Bueno @ 2006-08-09 13:41 UTC (permalink / raw)
  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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-09 13:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-04  1:03 ocamlc Stack_overflow Denis Bueno
2006-08-09  2:00 ` Denis Bueno
2006-08-09  2:54   ` [Caml-list] " Jon Harrop
2006-08-09  4:19   ` Martin Jambon
2006-08-09 13:41     ` Denis Bueno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).