[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: Eric Blake
Subject: Re: SEGFAULT if bash script make "source" for itself
Date: Thu, 28 Aug 2014 10:48:05 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

On 08/27/2014 07:07 PM, address@hidden wrote:
> Expected result:
> Block "source" for files already listed in "${BASH_SOURCE}". Perhaps this
> behavior and "changed" behavior should be switched by option in "set"
> command.

No.  Recursive sourcing is useful, don't prohibit it artificially.
Detecting which cases of user input would cause stack overflow is
equivalent to solving the Halting Problem, which is not practical.  So
our choices are to either cripple the user unnecessarily, or do a better
job in at least detecting after the fact when the user did something dumb.

> Or at least suitable error message if recursive "source" loop detected.

GNU libsigsegv is a library which provides the means for applications to
give a NICE error message when user input causes stack overflow.  For
example, both m4 and gawk use it so that a stack recursion exits
gracefully rather than with a segfault and core dump (after all, it's
the user's fault for putting in bad input, not a bug in the program).
Maybe it's worth investigating if bash could link with it?

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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