[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 13:08:30 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 |
On 08/28/2014 12:49 PM, address@hidden wrote:
> If follow this logic - we shoul try to catch incorrect user behaviour... we
> will got errors/signals from kernel.
>
> Simple situation:
> $ ((1/0))
> bash: ((: 1/0: division by 0 (error token is "0")
>
> Whey there is check on division by zero? We can predict this? - No. But we
> can detect it... and we out nice, detailed error message.
Actually, division by zero is fairly easy to check, and this is probably
a case where bash is checking for division by 0 up front rather than
handling SIGFPE after the fact.
>
> So why I should got SIGSEGV instead of nice, detailed error message in
> recursion? We can detect it?
GNU libsigsegv proves that it is possible to detect when SIGSEGV was
caused by stack overflow. It can't help prevent stack overflow, and you
_don't_ want to penalize your code by adding checking code into the
common case (if I'm about to overflow, error out instead), but leave
stack overflow as the exceptional case (if I've already overflowed and
received SIGSEGV, convert it into a nice error message to the user
before exiting cleanly, instead of the default behavior of dumping
core). But someone would have to write the patch for bash to link
against libsigsegv.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- SEGFAULT if bash script make "source" for itself, bogun.dmitriy, 2014/08/28
- Re: SEGFAULT if bash script make "source" for itself, Bob Proulx, 2014/08/28
- Re: SEGFAULT if bash script make "source" for itself, bogun.dmitriy, 2014/08/28
- Re: SEGFAULT if bash script make "source" for itself, Eric Blake, 2014/08/28
- Re: SEGFAULT if bash script make "source" for itself, bogun.dmitriy, 2014/08/28
- Re: SEGFAULT if bash script make "source" for itself, Eric Blake, 2014/08/28