bug-bash
[Top][All Lists]
Advanced

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

Bash crashes with trapped SIGCHLD and read -t.


From: konsolebox
Subject: Bash crashes with trapped SIGCHLD and read -t.
Date: Thu, 24 Jan 2013 21:35:24 +0800

Hi. Is there a way to prevent this segmentation fault in Bash? I'm not sure
where the fault happens but when there's a function that handles a trap and
when a signal is caught during a session of read with -t, Bash crashes. An
example code that makes this happen is this:

--------------------

#!/bin/bash

shopt -s -o monitor

function catch {
    echo catch.
}

trap catch SIGCHLD

while :; do
    echo summon.
    sleep 4s &
    echo :
    :
    echo disown.
    disown
    echo read.
    read -t 1
done

--------------------

The output would be something like this:

--------------------

...
summon.
:
disown.
read.
catch.
summon.
:
disown.
read.
catch.
*** glibc detected *** bash: double free or corruption (fasttop):
0x0000000000f18210 ***
Segmentation fault

--------------------

Sometimes there's also a message like:

--------------------

Inconsistency detected by ld.so: dl-open.c: 221: dl_open_worker: Assertion
`_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT' failed!

--------------------

It doesn't seem to crash though if the execution of the child process was
started outside just like in this script:

--------------------

#!/bin/bash

shopt -s -o monitor

function summon {
        echo summon.
        sleep 4s &
        disown
}

trap summon SIGCHLD

summon

while :; do
        echo read.
        read -t 1
done

--------------------

Is there a way to prevent that from happening? I've been having this
problem already since 2008. It happened in systems like Gentoo and
Slackware in all versions of Bash that I had used (at least starting 3.0).
And the current version of Bash that I'm using is 4.2.37.

It also rarely happens if I increase the length of timeout in read but it
still does happen sometimes.


reply via email to

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