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; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ messages in thread

* Re: [Caml-list] Ocamlc stack overflow
  2003-11-25 13:19   ` Alex Baretta
  2003-11-25 14:06     ` Richard Jones
@ 2003-11-25 17:50     ` Xavier Leroy
  1 sibling, 0 replies; 11+ messages in thread
From: Xavier Leroy @ 2003-11-25 17:50 UTC (permalink / raw)
  To: Alex Baretta; +Cc: caml-list

> Since my company uses ocaml as it's main language for 
> developing commercial applications, I'd prefer to have a stable stock 
> version. After all the turmoil around 3.07, a stable bugfix release is 
> overdue now.

It's called 3.07pl2 and has been available since Oct 20 at the usual
place (http://caml.inria.fr/).  (It is identical to 3.07 + patch 2,
for those who have applied the patch, but the tarball and binary
distributions were updated.)

> Let try to produce a backtrace for the list...
> #0  Pc : 824648  Errors char 2807
> #1  Pc : 68568  Format char 35089
> #2  Pc : 830376  Main char 5649
> #3  Pc : 834284  Main char 5678

That exception is caught and re-raised (for finalization purposes), so
you're just seeing the finalization point.  If you really want to
pinpoint the location of the error, either go back in time using
ocamldebug, or just run ocamlc outside ocamldebug with the "stack
backtrace" option set (OCAMLRUNPARAM=b).

> Now what?

What about sending some code to reproduce the problem to caml@inria.fr?
Or even better submit a bug report to caml-bugs@inria.fr with a URL to
the repro case?  (Remember: shouting "I have a bug!" on this list
accomplishes nothing beyond venting some steam.)
The repro case doesn't have to be small, all what is needed is that
it reproduces the problem.

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocamlc stack overflow
  2003-11-25 13:19   ` Alex Baretta
@ 2003-11-25 14:06     ` Richard Jones
  2003-11-25 17:50     ` Xavier Leroy
  1 sibling, 0 replies; 11+ messages in thread
From: Richard Jones @ 2003-11-25 14:06 UTC (permalink / raw)
  Cc: Ocaml

It's only 140 lines of code? Try chopping lines off the end of the
file until the thing compiles. Then you should be able to isolate
which statement causes the stack overflow. From there it should be a
simple enough job to either understand the problem and work around it,
or else come up with a minimal example which exhibits the bug.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocamlc stack overflow
  2003-11-24 17:47 ` Richard Jones
@ 2003-11-25 13:19   ` Alex Baretta
  2003-11-25 14:06     ` Richard Jones
  2003-11-25 17:50     ` Xavier Leroy
  0 siblings, 2 replies; 11+ messages in thread
From: Alex Baretta @ 2003-11-25 13:19 UTC (permalink / raw)
  To: Richard Jones; +Cc: Ocaml, Jacques Garrigue

Thanks for answering.

I finally managed to fix my mail client. I haven't been able to get 
anything from the list yesterday..

Richard Jones wrote:

> On Mon, Nov 24, 2003 at 06:21:07PM +0100, Alex Baretta wrote:
> 
>>I am experiencing stack overflows while compiling a source file with 
>>ocamlc. Why in world should ocamlc overflow? How can I diagnose the problem?
> 
> 
> We had this when compiling some OLE code (auto-generated ML). The
> workaround was to increase the stack size:

I am also trying to compile an auto-generated file, but it is rather 
small (140 lines of code). The binary search is probably not the way to 
go, but let me see what happens if I try to increase the stack size...

> export OCAMLRUNPARAM=l=16M

OK, done that...
ocamlc is presently running with 98% of the cpu and some 70 MB of memory 
footprint. It's almost certainly looping somewhere, allocating it's head 
off...

Damien Doligez wrote:
 > On Monday, November 24, 2003, at 06:21 PM, Alex Baretta wrote:
 >
 > If you are using the CVS version, you should try to update to the
 > latest one.  One version was committed last week with a stack
 > overflow problem.
 >
 > -- Damien

I am using the Xavier-patch 2 to ocaml-3.07. I'm not ehntusiastic about 
using CVS. Since my company uses ocaml as it's main language for 
developing commercial applications, I'd prefer to have a stable stock 
version. After all the turmoil around 3.07, a stable bugfix release is 
overdue now.

***

Let try to produce a backtrace for the list...

OK, so the standard ocamlc is compiled without debugging info. Let me 
tweak the Makefile, so that I can build a copy of ocamlc with the -g option.

Done that. Here's the command I'm using to run the debugger:
[alex@flyingtuxman anagrafiche]$ ocamldebug 
/opt/ocaml/3.07+2g/bin/ocamlc -I 
/opt/ocaml/3.07/lib/ocaml/site-lib/postgres -I 
/opt/ocaml/3.07/lib/ocaml/site-lib/cgi -I 
/home/alex/cvs/sw2/ocamllib-addons  -I /home/alex/cvs/sw2/unixlib-addons 
  -I /home/alex/cvs/sw2/rules-engine  -I 
/home/alex/cvs/sw2/xcaml/xcaml-lib  -I /home/alex/cvs/sw2/dbinterface 
-I /home/alex/cvs/sw2/freerp/db/db_access  -I 
/home/alex/cvs/sw2/freerp/lib  -I 
/home/alex/cvs/sw2/freerp/business_rules  -I /home/alex/cvs/sw2/dbschema 
  -I /home/alex/cvs/sw2/freerp/db/xcaml_db_schema  -I 
/home/alex/cvs/sw2/xcaml/xcaml-lib -c inserimento_enti_sql.ml
	Objective Caml Debugger version 3.07+2

(ocd) run
Loading program... done.
Time : 2766617
Program end.
Uncaught exception: Stack_overflow
(ocd) prev
Time : 2766616 - pc : 824648 - module Errors
No source file for Errors.
(ocd) bt
#0  Pc : 824648  Errors char 2807
#1  Pc : 68568  Format char 35089
#2  Pc : 830376  Main char 5649
#3  Pc : 834284  Main char 5678

************

Now what?

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocamlc stack overflow
  2003-11-24 17:21 [Caml-list] Ocamlc stack overflow Alex Baretta
  2003-11-24 17:47 ` Richard Jones
@ 2003-11-24 18:22 ` Damien Doligez
  1 sibling, 0 replies; 11+ messages in thread
From: Damien Doligez @ 2003-11-24 18:22 UTC (permalink / raw)
  To: Alex Baretta; +Cc: Ocaml

On Monday, November 24, 2003, at 06:21 PM, Alex Baretta wrote:

> I am experiencing stack overflows while compiling a source file with 
> ocamlc. Why in world should ocamlc overflow? How can I diagnose the 
> problem?

If you are using the CVS version, you should try to update to the
latest one.  One version was committed last week with a stack
overflow problem.

-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocamlc stack overflow
  2003-11-24 17:21 [Caml-list] Ocamlc stack overflow Alex Baretta
@ 2003-11-24 17:47 ` Richard Jones
  2003-11-25 13:19   ` Alex Baretta
  2003-11-24 18:22 ` Damien Doligez
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Jones @ 2003-11-24 17:47 UTC (permalink / raw)
  To: Alex Baretta; +Cc: Ocaml

On Mon, Nov 24, 2003 at 06:21:07PM +0100, Alex Baretta wrote:
> I am experiencing stack overflows while compiling a source file with 
> ocamlc. Why in world should ocamlc overflow? How can I diagnose the problem?

We had this when compiling some OLE code (auto-generated ML). The
workaround was to increase the stack size:

export OCAMLRUNPARAM=l=16M

As for diagnosing the problem: I imagine the following would work:

(1) Chop your file in half around the 50% mark. (Don't chop in the
middle of a statement, or somewhere which would cause an error).

(2) If that compiles successfully, then repeat, but chopping at the
75% mark. Otherwise if it fails, repeat chopping at the 25% mark.

(3) Continue like so doing a binary search until you find out where it
crashes.

In the OLE case it appeared to crash simply because of the size of the
file, rather than any specific OCaml statement.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
"One serious obstacle to the adoption of good programming languages is
the notion that everything has to be sacrificed for speed. In computer
languages as in life, speed kills." -- Mike Vanier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Ocamlc stack overflow
@ 2003-11-24 17:21 Alex Baretta
  2003-11-24 17:47 ` Richard Jones
  2003-11-24 18:22 ` Damien Doligez
  0 siblings, 2 replies; 11+ messages in thread
From: Alex Baretta @ 2003-11-24 17:21 UTC (permalink / raw)
  To: Ocaml

I am experiencing stack overflows while compiling a source file with 
ocamlc. Why in world should ocamlc overflow? How can I diagnose the problem?

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

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

Thread overview: 11+ 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
  -- strict thread matches above, loose matches on Subject: below --
2003-11-24 17:21 [Caml-list] Ocamlc stack overflow Alex Baretta
2003-11-24 17:47 ` Richard Jones
2003-11-25 13:19   ` Alex Baretta
2003-11-25 14:06     ` Richard Jones
2003-11-25 17:50     ` Xavier Leroy
2003-11-24 18:22 ` Damien Doligez

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).