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.
Bug 1267912 - malloc() signal leak in lexsave() [RHEL-7]
Summary: malloc() signal leak in lexsave() [RHEL-7]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: zsh
Version: 7.2
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Jan Kepler
Robert Krátký
URL:
Whiteboard:
Depends On:
Blocks: 1203710 1267903 1289025 1295396 1295829 1313485 1338885
TreeView+ depends on / blocked
 
Reported: 2015-10-01 11:38 UTC by Kamil Dudka
Modified: 2019-10-10 10:16 UTC (History)
6 users (show)

Fixed In Version: zsh-5.0.2-17.el7
Doc Type: Bug Fix
Doc Text:
*zsh* no longer deadlocks on `malloc()` execution Previously, if the *zsh* process received a signal during the execution of a memory allocation function and the signal handler attempted to allocate or free memory, *zsh* entered a deadlock and became unresponsive. With this update, signal handlers are no longer enabled while handling the global state of *zsh* or while using the heap memory allocator. This ensures that the described deadlock no longer occurs.
Clone Of: 1267903
: 1338885 (view as bug list)
Environment:
Last Closed: 2016-11-03 23:02:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2152 0 normal SHIPPED_LIVE zsh bug fix update 2016-11-03 13:13:01 UTC

Description Kamil Dudka 2015-10-01 11:38:48 UTC
+++ 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.

Comment 8 Robert Krátký 2016-08-21 15:40:33 UTC
Hi Kamil,

Could you please check the Release Notes text?

Thank you.

Comment 13 errata-xmlrpc 2016-11-03 23:02:21 UTC
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


Note You need to log in before you can comment on or make changes to this bug.