bug-bash
[Top][All Lists]
Advanced

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

Re: BASH recursion segfault, FUNCNEST doesn't help


From: Chet Ramey
Subject: Re: BASH recursion segfault, FUNCNEST doesn't help
Date: Mon, 6 Jun 2022 10:14:31 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0

On 6/2/22 4:00 PM, Gergely wrote:

I could not produce a scenario in 15 minutes that would indicate that
this corrupts other sections, as there is a considerable gap between the
stack and everything else. This is OS-dependent though and bash has no
control over what happens should this occur.

Because you haven't forced bash to write outside its own address space or
corrupt another area on the stack. This is a resource exhaustion issue,
no more.


Well, the issue is not the fact that this is a resource exhaustion, but
rather the fact that it's entirely OS-dependent and the programmer has
zero control over it.

The programmer has complete control over this, at least in the scenario you
reported.

What happens should the situation occur, is not up
to bash or the programmer. The behaviour is not portable and not
recoverable. A programmer might expect a situation like this, but there
is no knob to turn to prevent an abrupt termination, unlike FUNCNEST.

If you think it's more valuable, you can build bash with a definition for
SOURCENEST_MAX that you find acceptable. There's no user-visible variable
to control that; it's just not something that many people request. But it's
there if you (or a distro) want to build it in.

Speaking for myself, I'd find an error a much MUCH more palatable
condition than a segfault in this case. In the case of an error I at
least have a chance to do cleanup or emit a message, as opposed to just
terminating out of the blue. I don't think most bash programs are
written with the expectation that they might seize to run any moment
without any warning.

I think anyone who codes up an infinite recursion should expect abrupt
termination. Any other scenario is variable and controlled by resource
limits.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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