Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 710668

Summary: using gdb to debug kernel causes crash
Product: Red Hat Enterprise Linux 6 Reporter: Michael Hebenstreit <michael.hebenstreit>
Component: kernelAssignee: Prarit Bhargava <prarit>
Status: CLOSED ERRATA QA Contact: WANG Chao <chaowang>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: arozansk, czhang, phan, ruyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-2.6.32-171.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 13:32:50 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
RHEL6 patch for this issue none

Description Michael Hebenstreit 2011-06-04 00:03:23 UTC
Description of problem:
kernel misses a bugfix to cover GDB 6.8 -> 7.2 changes
bug alread described in http://sourceware.org/bugzilla/show_bug.cgi?id=12146
fix in http://kerneltrap.org/mailarchive/linux-kernel/2010/7/22/4596723

Comment 2 Prarit Bhargava 2011-06-10 11:42:44 UTC
Hi Michael,

I'm not set up to run gdb here -- you seem knowledgeable enough to backport the patch and test.  Would you mind doing so and posting the result here?

I can then see about backporting it to RHEL6.

Thanks :)

P.

Comment 3 Michael Hebenstreit 2011-06-10 15:29:47 UTC
I used thia patch, seems to work now:

[mhebenst@eln1 development]$ cat linux-2.6.32-131.0.15.el6.x86_64.crt.1.debug/kgdb_1.patch
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 4b17b32..e8fd686 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -621,10 +621,8 @@ static void gdb_cmd_query(struct kgdb_state *ks)
        switch (remcom_in_buffer[1]) {
        case 's':
        case 'f':
-               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
                        break;
-               }

                i = 0;
                remcom_out_buffer[0] = 'm';
@@ -665,10 +663,9 @@ static void gdb_cmd_query(struct kgdb_state *ks)
                pack_threadid(remcom_out_buffer + 2, thref);
                break;
        case 'T':
-               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
                        break;
-               }
+
                ks->threadid = 0;
                ptr = remcom_in_buffer + 17;
                kgdb_hex2long(&ptr, &ks->threadid);

Comment 4 Prarit Bhargava 2011-07-13 14:26:29 UTC
Michael, thanks for testing.  I will compile test and push for internal review.

Again, thanks :)

P.

Comment 5 Prarit Bhargava 2011-07-13 17:18:34 UTC
Michael,

... are you sure that's the patch?  I don't see a kernel/debug/ dir in RHEL6...

P.

Comment 6 Michael Hebenstreit 2011-07-13 17:37:13 UTC
ups - you are right - I posted the original patch - here is my change to the RH kernel - second try:

--- linux-2.6.32-131.0.15.el6.x86_64.crt.1/kernel/kgdb.c     2009-12-02 19:51:21.000000000 -0800
+++ linux-2.6.32-131.0.15.el6.x86_64.crt.1.debug/kernel/kgdb.c 2011-06-03 16:12:29.596472000 -0700
@@ -1001,10 +1001,8 @@
        switch (remcom_in_buffer[1]) {
        case 's':
        case 'f':
-               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
                        break;
-               }

                i = 0;
                remcom_out_buffer[0] = 'm';
@@ -1045,10 +1043,9 @@
                pack_threadid(remcom_out_buffer + 2, thref);
                break;
        case 'T':
-               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
                        break;
-               }
+
                ks->threadid = 0;
                ptr = remcom_in_buffer + 17;
                kgdb_hex2long(&ptr, &ks->threadid);

Comment 7 Prarit Bhargava 2011-07-13 18:08:52 UTC
(In reply to comment #6)
> ups - you are right - I posted the original patch - here is my change to the RH
> kernel - second try:
> 

Heh ... np :)   I thought that was the what you backported to but I just wanted to make sure I post what you tested :)

P.

Comment 8 Prarit Bhargava 2011-07-13 19:00:17 UTC
Created attachment 512725 [details]
RHEL6 patch for this issue

Comment 9 RHEL Program Management 2011-07-13 19:21:12 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux maintenance release. Product Management has 
requested further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed 
products. This request is not yet committed for inclusion in an Update release.

Comment 11 Kyle McMartin 2011-07-25 13:07:15 UTC
Patch(es) available on kernel-2.6.32-171.el6

Comment 15 WANG Chao 2011-11-09 04:31:36 UTC
Just to mark how I setup kgdb environment:
connect console serial port between two machines as target:/dev/ttyS0 <--> development:/dev/ttyUSB0
On target machine, add kernel param 'kgdboc=ttyS0,115200 kgdbwait'.
On development machine, use gdb to load kernel-debuginfo/vmlinux.
   
Reproduce on 2.6.32-131.15.el6:
[snip]
Reading symbols from /root/vmlinux-131...done.
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0xffffffff810d42bb in kgdb_initial_breakpoint (new_kgdb_io_ops=0xffffffff81afe6e0) at kernel/kgdb.c:1630
1630		printk(KERN_CRIT "kgdb: Waiting for connection from remote gdb...\n");
trace API error 0x2.
(gdb) quit

Verified on 2.6.32-216.el6:
[snip]
Reading symbols from /root/vmlinux-214...done.
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
kgdb_breakpoint (new_kgdb_io_ops=0xffffffff81aff4a0) at kernel/kgdb.c:1718
1718		wmb(); /* Sync point after breakpoint */
(gdb) quit
A debugging session is active.

	Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y

On 2.6.32-216.el6, kgdb works correctly as expected(no error message)

Set bug status to verified.

Comment 16 errata-xmlrpc 2011-12-06 13:32:50 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.

http://rhn.redhat.com/errata/RHSA-2011-1530.html