From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlc, ocamlopt stackoverflow on list
Date: Fri, 30 Nov 2012 14:20:42 +0100 [thread overview]
Message-ID: <CAPFanBEDbM58BqSy=Rwrn6K3ET2yxf5LnARzfuAsUtTyYyTjGw@mail.gmail.com> (raw)
In-Reply-To: <50B8AB75.5030508@univ-savoie.fr>
My (entirely personal) understanding of the matter is that making
every part of the compiler tail-recursive is a pain in the ass, and
the kind of issues that never really stop happening (fix some case and
the stack will blow somewhere else). Given the potential decrease of
readability¹ that such changes may incur, there is even less incentive
to accept fixes on these issues.
¹: and eventual decrease of performance on small inputs, even if that
is less important in the compiler code
I would therefore suggest changing the generated code to look like the
following (modulo order-of-evaluation issues):
let li = 29000::29001::...::[] in
let li = 28000::28001::...::li in
...
let li = 0::1::2::...::li in
li
Remark: if the list is "quadratically too long", you may still
segfault because of the excessive nesting of (let .. in ..) in this
code. I'm unsure this could happen with a reasonable lower bound on
permitted stack usage, but this could be fixed as well with another
level of splitting: let li = (let li = ... in let li = ... in ... li)
in let li = ( ... ) in ...
On Fri, Nov 30, 2012 at 1:49 PM, Christophe Raffalli
<christophe.raffalli@univ-savoie.fr> wrote:
>
> On my machine (ocaml 3.12.1 on linux 64 bits) with unlimited stack,
> ocamlc and ocamlopt fails to compile a list constant of length 30000
> which is a problem in code generated by another program.
next prev parent reply other threads:[~2012-11-30 13:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 9:26 [Caml-list] Higher order functors over tuples Ivan Gotovchits
2012-10-31 11:09 ` Didier Cassirame
2012-10-31 12:02 ` Ivan Gotovchits
2012-11-30 12:49 ` [Caml-list] ocamlc, ocamlopt stackoverflow on list Christophe Raffalli
2012-11-30 13:20 ` Gabriel Scherer [this message]
2012-11-30 13:31 ` Christophe Raffalli
2012-11-30 14:15 ` Gabriel Scherer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPFanBEDbM58BqSy=Rwrn6K3ET2yxf5LnARzfuAsUtTyYyTjGw@mail.gmail.com' \
--to=gabriel.scherer@gmail.com \
--cc=caml-list@inria.fr \
--cc=christophe.raffalli@univ-savoie.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).