[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SEGFAULT if bash script make "source" for itself

From: bogun.dmitriy
Subject: Re: SEGFAULT if bash script make "source" for itself
Date: Thu, 28 Aug 2014 13:57:20 -0700

2014-08-28 11:54 GMT-07:00 Greg Wooledge <address@hidden>:

> On Thu, Aug 28, 2014 at 11:49:02AM -0700, address@hidden wrote:
> > So why I should got SIGSEGV instead of nice, detailed error message in
> > recursion? We can detect it?
> You can't detect that it's going to happen.  You can only receive the
> SIGSEGV *after* it happens.
> We already have a configurable switch that would have prevented your
> original issue:
>       Functions may be recursive.  The FUNCNEST variable may be used to
>       limit the depth of the function call stack and restrict the number of
>       function invocations.  By default, no limit is imposed on the number
>       of recursive calls.
> Just export FUNCNEST=1000 somewhere in your dotfiles and you'll never
> have this particular seg fault again (assuming all your scripts run in
> an environment that inherits this).
This is not true:
$ export FUNCNEST=5
$ bash b.sh
Segmentation fault
$ cat b.sh

set -e
source "$(dirname ${BASH_SOURCE[0]}/c.sh)"

> The default of 0 is quite reasonable, as others have already explained.
Ok. Let be 0 by default. But we still need option/variable to limit
"source" recursion. Especially if we have such limit for function recursion

reply via email to

[Prev in Thread] Current Thread [Next in Thread]