Bug 108682

Summary: Gdb segfaults after using command script associated with breakpoint
Product: [Retired] Red Hat Linux Reporter: Enrique Perez-Terron <enrio>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED CANTFIX QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 9CC: cagney, jan.kratochvil, jjohnstn, mattdm
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-01-02 19:00:04 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:

Description Enrique Perez-Terron 2003-10-31 04:05:25 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.5) Gecko/20031016

Description of problem:
Using the gdb command "commands" to associate a script of gdb commands with a
breakpoint, gdb segfaults. The problem seems to be related to the use of a
"continue" command in the body of an "if" command.

Although this message does not appear in the first example below, in some cases
I get a warning message from gdb saying

   warning: invalid control type in command structure

The first example below was created with the current gdb,
gdb-5.3post-0.20021129.18. 

I repeated the exactly same experiment  with gdb-6.0 compiled with "./configure
--prefix=/usr; make; make install", and this time the warning message did show up.

How reproducible:
Always

Steps to Reproduce:
1. Type the following test program and save it as /tmp/gdb-test.c:

static void stopme()
{
}

int main(int argc, char *argv[])
{
   int i;
   for (i=0; i < 3; ++i)
      stopme();
}

2. compile it with gcc -g -o gdb-test gdb-test.c
3. Prepare a script of gdb commands in a file /tmp/gdb-script:

    set $a = 0
    b stopme
    command
    set $a = $a + 1
    if $a < 3
    cont
    end
    end
    run

Start gdb and issue the single command "source /tmp/gdb-script"

Actual Results:  Debugger segmentation fault

Expected Results:  Gdb should stop after reaching the breakpoint 
the third time, and issue a new promt.


Additional info:

Here is the complete contents of the emacs debugger buffer:

Current directory is /tmp/
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB 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.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) source gdb-script
Breakpoint 1 at 0x80482f7: file gdb-test.c, line 3.

Breakpoint 1, stopme () at gdb-test.c:3

Breakpoint 1, stopme () at gdb-test.c:3

Debugger segmentation fault

------

After removing the gdb rpm and installing gdb-6.0 from source tarball, I
repeated the experiment with the following results:

Current directory is /tmp/
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB 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.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu"...
(gdb) source /tmp/gdb-script
Breakpoint 1 at 0x80482f7: file gdb-test.c, line 3.

Breakpoint 1, stopme () at gdb-test.c:3

Breakpoint 1, stopme () at gdb-test.c:3

Breakpoint 1, stopme () at gdb-test.c:3
warning: Invalid control type in command structure.

Program exited with code 0204.

Debugger segmentation fault


In case I have used wrong syntax or similar, consider improving the
docuemtation. I have used the gdb command "help if".

Comment 1 Jan Kratochvil 2006-07-25 12:09:39 UTC
Not reproducible on FC5 (gdb-6.3.0.0-1.122), to be closed as CLOSED-CURRENTRELEASE.

(gdb) source /tmp/gdb-script
Breakpoint 1 at 0x8048357: file gdb-test.c, line 3.

Breakpoint 1, stopme () at gdb-test.c:3
3       }

Breakpoint 1, stopme () at gdb-test.c:3
3       }

Breakpoint 1, stopme () at gdb-test.c:3
3       }
(gdb) 


Comment 2 Bill Nottingham 2006-08-05 04:30:33 UTC
Red Hat apologizes that these issues have not been resolved yet. We do want to
make sure that no important bugs slip through the cracks.

Red Hat Linux 7.3 and Red Hat Linux 9 are no longer supported by Red Hat, Inc.
They are maintained by the Fedora Legacy project (http://www.fedoralegacy.org/)
for security updates only. If this is a security issue, please reassign to the
'Fedora Legacy' product in bugzilla. Please note that Legacy security update
support for these products will stop on December 31st, 2006.

If this is not a security issue, please check if this issue is still present
in a current Fedora Core release. If so, please change the product and version
to match, and check the box indicating that the requested information has been
provided.

If you are currently still running Red Hat Linux 7.3 or 9, please note that
Fedora Legacy security update support for these products will stop on December
31st, 2006. You are strongly advised to upgrade to a current Fedora Core release
or Red Hat Enterprise Linux or comparable. Some information on which option may
be right for you is available at http://www.redhat.com/rhel/migrate/redhatlinux/.

Any bug still open against Red Hat Linux 7.3 or 9 at the end of 2006 will be
closed 'CANTFIX'. Again, if this bug still exists in a current release, or is a
security issue, please change the product as necessary. We thank you for your
help, and apologize again that we haven't handled these issues to this point.


Comment 4 Bill Nottingham 2007-01-02 19:00:04 UTC
Red Hat Linux 7.3 and Red Hat Linux 9 are no longer supported by Red Hat, Inc.
f you are currently still running Red Hat Linux 7.3 or 9, you are strongly
advised to upgrade to a current Fedora Core release or Red Hat Enterprise Linux
or comparable. Some information on which option may be right for you is
available at http://www.redhat.com/rhel/migrate/redhatlinux/.

Closing as CANTFIX.