Red Hat Bugzilla – Bug 1267912
malloc() signal leak in lexsave() [RHEL-7]
Last modified: 2016-11-03 19:02:21 EDT
+++ This bug was initially created as a clone of Bug #1267903 +++ 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. --- Additional comment from Kamil Dudka on 2015-10-01 13:30:30 CEST --- (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.
Hi Kamil, Could you please check the Release Notes text? Thank you.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2016-2152.html