Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 555076

Summary: gcore fails in small terminals
Product: Red Hat Enterprise Linux 5 Reporter: Jeff Bastian <jbastian>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: cagney, jakub, pmuller, tromey
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-7.0.1-26.el5 Doc Type: Bug Fix
Doc Text:
When running the gcore command, GDB could have prompted the user to allow pagination and then fail. This occurred if the terminal window was too small for the output returned by the external gcore program. With this update, the gcore standalone command runs non-interactively.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-13 23:53:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
gcore height patch none

Description Jeff Bastian 2010-01-13 15:54:56 UTC
Description of problem:
gcore can fail to dump a core file in a terminal window that's too short (too few lines).  This is because gcore runs gdb with STDIN redirected from /dev/null, but if there's a lot of output, gdb will prompt
   ---Type <return> to continue, or q <return> to quit---
and fail.

To fix this, just add a 'set height 0' line in the gdb batch commands.

Version-Release number of selected component (if applicable):
gdb-6.8-37.el5

How reproducible:
every time

Steps to Reproduce:
1. save this program as test-gcore.c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
        sleep(120);
        return(0);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. compile test.c with a lot of shared libraries
gcc -I. -c -o test-gcore.o test-gcore.c
gcc -I. -o test-gcore test-gcore.o -L/usr/lib -ldl -lrpm -lrpmio -lpopt \
    -lz -lcrypto -lm -lssl -lxml2 -lxmlsec1 -lxslt -L/usr/lib/lib \
    -lwrap -Wl,-E \
    -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE \
    -L/usr/local/lib \
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a \
    -L/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -lperl \
    -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

3. ./test-gcore &

4. xterm -geometry 80x10 &

5. in the small xterm:
     gcore `pidof test-gcore`

Actual results:
(no debugging symbols found)
(no debugging symbols found)
...
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f22940 (LWP 15018)]
---Type <return> to continue, or q <return> to quit---0x00dda402 in __kernel_vsyscall ()
gcore: failed to create core.15018

Expected results:
successfully create a core of test-gcore

Additional info:
This will fix the problem:
--- /usr/bin/gcore      2010-01-13 03:06:37.000000000 -0500
+++ /usr/bin/gcore.new  2010-01-13 10:50:57.000000000 -0500
@@ -64,6 +64,7 @@
        # Write gdb script for pid $pid.
        cat >>$tmpfile <<EOF
 attach $pid
+set height 0
 gcore $name.$pid
 detach
 quit

Comment 1 Jeff Bastian 2010-01-13 15:56:52 UTC
Created attachment 383507 [details]
gcore height patch

Comment 2 Jan Kratochvil 2010-01-13 18:34:51 UTC
OK, nice catch.

Moreover maybe the commandline "-batch" option should be extended to have more wide functionality and due such tunings on its own.

Comment 3 Jeff Bastian 2010-01-13 18:52:42 UTC
Fedora 12 gdb-7.0.1-19.fc12 does not have this problem; maybe -batch in the newer gdb already takes care of this?

Comment 4 Tom Tromey 2010-01-29 22:00:07 UTC
Nope, it is just a gdb oddity.  I filed it upstream a while ago:
http://sourceware.org/bugzilla/show_bug.cgi?id=9591

Comment 5 Tom Tromey 2010-03-11 19:28:55 UTC
FWIW the upstream bug has been fixed.
-batch now disables pagination and queries.

Comment 9 Eva Kopalova 2010-11-16 16:58:27 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When running the gcore command, GDB could have prompted the user to allow pagination and then fail. This occurred if the terminal window was too small for the output returned by the external gcore program. With this update, the gcore standalone command runs non-interactively.

Comment 10 Chris Ward 2010-11-18 12:22:05 UTC
~~ ATTN Customers & Partners - RHEL 5.6 Public Beta available on RHN ~~

A fix for this BZ should be present and testable in the release. 

If this Bugzilla is verified as resolved, please update the Verified field
above with an appropriate value and include a summary of the testing executed
and the results obtained.

If you encounter any issues or have questions while testing, please describe
them and set this bug into NEED_INFO. 

If you encounter new defects or have additional patches to request for
inclusion, promptly escalate the new issues through your support
representative.

Finally, FYI: future Beta kernels can be found here:
 http://people.redhat.com/jwilson/el5/

Note: Bugs with the 'OtherQA' keyword require Third-Party testing to confirm
the request has been properly addressed. 
See:
 https://bugzilla.redhat.com/describekeywords.cgi#OtherQA

Comment 13 errata-xmlrpc 2011-01-13 23:53:26 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0099.html