Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Cause:
Signal handlers were enabled during the execution of malloc() in the implementation of lexsave().
Consequence:
If a signal was received during the execution of malloc() and its handler attempted to allocate or free memory, the zsh process ended up in a deadlock and became unresponsive.
Fix:
Signal handlers are no longer enabled during the execution of malloc(). Instead of that, signals are queued for processing upon the return from malloc().
Result:
The deadlock no longer occurs.
Description of problem:
zsh deadlocks in futex-wait state when signal hit in malloc() called by lexsave():
#0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97
97 2: movl %edx, %eax
(gdb) bt
#0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97
#1 0x0000003eb427d0a0 in _L_lock_5189 () from /lib64/libc-2.12.so
#2 0x0000003eb42789fb in _int_free (av=0x3eb458fe80, p=0x2174940, have_lock=0) at malloc.c:4959
...
#7 0x0000000000474495 in zhandler (sig=17) at signals.c:584
#8 <signal handler called>
#9 _int_malloc (av=0x3eb458fe80, bytes=<value optimized out>) at malloc.c:4538
#10 0x0000003eb427a991 in __libc_malloc (bytes=264) at malloc.c:3664
#11 0x000000000044a96b in lexsave () at lex.c:252
Version-Release number of selected component (if applicable):
zsh-4.3.11-4.el6.x86_64
How reproducible:
happens in production environment, not reproduced in labs so far
Steps to Reproduce:
1.
2.
3.
Actual results:
zsh deadlocks in futex-wait state
Expected results:
no deadlocks
Additional info:
The bug appears not to affect upstream master, where the function
lexsave(void)
... 1x malloc, 1x zalloc
was rewritten to
lex_context_save(struct lex_stack *ls, int toplevel)
... no *alloc at all
Recheck of any possible malloc() signal leaks in current RHEL 6 zsh code needed.
(In reply to Filip Krska from comment #0)
> Description of problem:
>
> zsh deadlocks in futex-wait state when signal hit in malloc() called by
> lexsave():
>
>
> #0 __lll_lock_wait_private () at
> ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97
> 97 2: movl %edx, %eax
> (gdb) bt
> #0 __lll_lock_wait_private () at
> ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97
> #1 0x0000003eb427d0a0 in _L_lock_5189 () from /lib64/libc-2.12.so
> #2 0x0000003eb42789fb in _int_free (av=0x3eb458fe80, p=0x2174940,
> have_lock=0) at malloc.c:4959
> ...
> #7 0x0000000000474495 in zhandler (sig=17) at signals.c:584
> #8 <signal handler called>
> #9 _int_malloc (av=0x3eb458fe80, bytes=<value optimized out>) at
> malloc.c:4538
> #10 0x0000003eb427a991 in __libc_malloc (bytes=264) at malloc.c:3664
> #11 0x000000000044a96b in lexsave () at lex.c:252
I agree that replacing malloc() by zalloc() will prevent the above backtrace.
> Recheck of any possible malloc() signal leaks in current RHEL 6 zsh code
> needed.
It is unfortunately not that easy. Calling [z]free() can also cause such a deadlock. Upstream discouraged from wrapping [z]free() by signal queuing globally because it could hide unprotected accesses to the global state and result in wrong behavior (which is actually worse than the deadlock).
The handling of signals is still not perfect even in the latest upstream version of zsh. See bug #1198671 for the list of related upstream fixes. Unfortunately, new bug reports are still coming on the upstream mailing list.
(In reply to Filip Krska from comment #0)
> Recheck of any possible malloc() signal leaks in current RHEL 6 zsh code
> needed.
I have found one more occurrence (still present in the latest upstream):
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1289,18 +1289,23 @@ zsfree(char *p)
MALLOC_RET_T
realloc(MALLOC_RET_T p, MALLOC_ARG_T size)
{
struct m_hdr *m = (struct m_hdr *)(((char *)p) - M_ISIZE), *mp, *mt;
char *r;
int i, l = 0;
/* some system..., see above */
- if (!p && size)
- return (MALLOC_RET_T) malloc(size);
+ if (!p && size) {
+ queue_signals();
+ r = malloc(size);
+ unqueue_signals();
+ return (MALLOC_RET_T) r;
+ }
+
/* and some systems even do this... */
if (!p || !size)
return (MALLOC_RET_T) p;
queue_signals(); /* just queue signals caught rather than handling them */
/* check if we are reallocating a small block, if we do, we have
to compute the size of the block from the sort of block it is in */
The fix for this bug has been delivered in RHEL 6.7.z and this component has not been updated in RHEL 6.8. RHEL 6.8 contains the fix from RHEL 6.7.z. Therefore, this bug has been closed as CURRENTRELEASE.