[mercury-users] List Append segfault
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Jan 3 10:55:44 AEDT 2003
On 02-Jan-2003, Michael Day <mikeday at yeslogic.com> wrote:
>
> List append:
>
> Foo ++ Bar -> works
> Bar ++ Foo -> segfaults
>
> in hlc.par.gc with a recent (pre 0.11.0) rotd.
>
> Foo is quite long, Bar is very long (up to 100,000 items).
>
> Out of stack?
Yes, that is the most likely explanation, especially if you
are using a system on which Mercury normally traps stack
If you are using a Unix system, e.g. Linux, you can use the `ulimit' command
to show the stack limit. For (ba)sh, the Bourne shell commands
ulimit -S -a
ulimit -H -a
will show all the soft and hard limits. You can also use
`ulimit -s <amount in kilobytes>' to set the soft limit.
For (t)csh, see the documentation of the `limit' command.
> Shouldn't segfault though...
Unfortunately, facilities for trapping overflow of the system stack
are quite non-portable. The normal mechanisms for trapping segfaults --
signal handlers -- don't work for trapping stack overflow, since there
is no stack space available for calling the signal handler. Some
operating systems provide special support for this, e.g. via
sigaltstack(), but AFAIK there is no such support under Linux.
Furthermore, in general it is not safe to attempt to recover from stack
overflows (e.g. via longjmp) and continue execution, because stack
overflow can occur during the execution of standard C library routines
(e.g. malloc) at points where locks are held, or where invariants of
global data structures don't hold; thus subsequent execution may result
in deadlock, or worse.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list