On 2/11/17 5:04 PM, Graham Northup wrote: > Bash Version: 4.4 > Patch Level: 11 > Release Status: release > > Description: > > I'm getting a mysterious hang on one of our Arch Linux machines for a > particular, rather simple script; getting a debugger attached to the > process after building some debugging symbols, I tracked the hang down > to this loop in bgp_delete (with some minor formatting):
It seems obvious in retrospect that the cause is in bgp_add, where there's no check for the hashed pid colliding with the index into the pidstat list. Here's a patch that avoids that issue and catches the symptom you found in case the cause is something else. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.4-patched/jobs.c 2016-11-11 14:06:24.000000000 -0500 --- jobs.c 2017-02-16 11:07:13.000000000 -0500 *************** *** 815,818 **** --- 798,812 ---- bucket = pshash_getbucket (pid); psi = bgp_getindex (); + + /* XXX - what if psi == *bucket? */ + if (psi == *bucket) + { + #ifdef DEBUG + internal_warning ("hashed pid %d (pid %d) collides with bgpids.head, skipping", psi, pid); + #endif + bgpids.storage[psi].pid = NO_PID; /* make sure */ + psi = bgp_getindex (); /* skip to next one */ + } + ps = &bgpids.storage[psi]; *************** *** 866,871 **** /* Search chain using hash to find bucket in pidstat_table */ for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next) ! if (bgpids.storage[psi].pid == pid) ! break; if (psi == NO_PIDSTAT) --- 860,872 ---- /* Search chain using hash to find bucket in pidstat_table */ for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next) ! { ! if (bgpids.storage[psi].pid == pid) ! break; ! if (psi == bgpids.storage[psi].bucket_next) /* catch reported bug */ ! { ! internal_warning ("bgp_delete: BUG: psi (%d) == storage[psi].bucket_next", psi); ! return 0; ! } ! } if (psi == NO_PIDSTAT)
signature.asc
Description: OpenPGP digital signature