Bug 1656165 - readline library's tab completion facility may trigger SIGSEGV
Summary: readline library's tab completion facility may trigger SIGSEGV
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: crash
Version: 7.7
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Dave Anderson
QA Contact: Emma Wu
Depends On:
Blocks: 1647768
TreeView+ depends on / blocked
Reported: 2018-12-04 21:09 UTC by Sterling Alexander
Modified: 2019-10-22 14:00 UTC (History)
4 users (show)

Fixed In Version: crash-7.2.3-9.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-08-06 12:41:17 UTC
Target Upstream Version:

Attachments (Terms of Use)
Crash session that crashed (30.07 KB, text/plain)
2018-12-04 21:09 UTC, Sterling Alexander
no flags Details

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2071 0 None None None 2019-08-06 12:41:21 UTC

Description Sterling Alexander 2018-12-04 21:09:47 UTC
Created attachment 1511468 [details]
Crash session that crashed

Description of problem:  Crash crashes when examining the following retrace task on optimus:

crash> sys
      KERNEL: /cores/retrace/repos/kernel/x86_64/usr/lib/debug/lib/modules/2.6.32-696.13.2.el6.x86_64/vmlinux
    DUMPFILE: /cores/retrace/tasks/110186978/crash/vmcore  [PARTIAL DUMP]
        CPUS: 8 [OFFLINE: 7]
        DATE: Mon Feb  5 04:13:11 2018
      UPTIME: 80 days, 07:36:30
LOAD AVERAGE: 145.48, 121.62, 81.48
       TASKS: 1093
     RELEASE: 2.6.32-696.13.2.el6.x86_64
     VERSION: #1 SMP Fri Sep 22 12:32:14 EDT 2017
     MACHINE: x86_64  (2396 Mhz)
      MEMORY: 32 GB
       PANIC: "Kernel panic - not syncing: hung_task: blocked tasks"

Version-Release number of selected component (if applicable):

$ crash --version

crash 7.2.4
Copyright (C) 2002-2017  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011  NEC Corporation
Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions.  Enter "help copying" to see the conditions.
This program has absolutely no warranty.  Enter "help warranty" for details.
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".

How reproducible:  Happened several times, full session log attached to the BZ

Steps to Reproduce:
1.  Use crash to analyse the core

Actual results:  Crash crashes

Expected results:  Crash doesn't crash

Additional info:

Comment 2 Dave Anderson 2018-12-05 15:18:18 UTC
I've never used the readline library's tab-completion feature in the crash
utility (I didn't even consider it being enabled).  I'm certainly not
familiar with the library's internals, so don't hold your breath awaiting
a fix.

Comment 4 Dave Anderson 2018-12-05 16:35:07 UTC
The failure can occur in multiple different paths, where the damage has
been done before the corruption is recognized.  Here's a couple more
relevant backtraces than the one in the attached file, where the failure
occurs while executing the readline() call:

crash> whatis mu*** Error in `./crash': free(): invalid pointer: 0x00007f095e62a000 ***
======= Backtrace: =========

crash> whatis mu*** Error in `./crash': malloc(): memory corruption: 0x00007feeec3f7010 ***
======= Backtrace: =========

The rl_completion_matches() function is where the transition is made
from the readline library code to base gdb code.

Comment 5 Dave Anderson 2018-12-06 18:25:32 UTC
I can't really figure out how to effectively debug this, given that the damage
has been done by the time the malloc/free/corruption is detected.  Staring
at the code doesn't show anything obvious.  My best guess is that it has
more to do with the embedded gdb completion code than the readline library
itself.  Or perhaps it's an issue related to the crash/gdb marriage, where
it is the only place where gdb code is invoked directly without the top-level
crash utility invoking gdb through its well-defined interface.  That alone is
a little bit disconcerting.

Anyway, I think I'll take a look at writing a readline completer plugin,
which would take gdb totally out of the picture.  It should be faster than
using the gdb completer, and would also remove the useless clutter of 
showing filenames as a completion option, which makes no sense.

Comment 6 Dave Anderson 2018-12-07 20:36:24 UTC
> ...
> Anyway, I think I'll take a look at writing a readline completer plugin,
> which would take gdb totally out of the picture.  It should be faster than
> using the gdb completer, and would also remove the useless clutter of 
> showing filenames as a completion option, which makes no sense.

A patch has been applied upstream:


  Implemented a new plugin function for the readline library's tab
  completion feature.  Without the patch, the use of the default plugin
  from the embedded gdb module has been seen to cause segmentation
  violations or other fatal malloc/free/corruption assertions.  The new
  plugin takes gdb out of the picture entirely, and also restricts the
  matching options to just symbol names, so as not to clutter the
  results with irrelevant filenames.

Also, because the top-level crash code already has a symbol list, the new
plugin avoids having to do the malloc/realloc/frees that the gdb code
does in generating the list of matching options -- which is where I 
*believe* the reported problem lies.

Comment 13 errata-xmlrpc 2019-08-06 12:41:17 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.


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