Bug 247427

Summary: utrace: i386 debugger + x86_64 kernel + threaded (i386) inferior = error
Product: Red Hat Enterprise Linux 5 Reporter: Jan Kratochvil <jan.kratochvil>
Component: kernelAssignee: Roland McGrath <roland>
Status: CLOSED ERRATA QA Contact: Martin Jenner <mjenner>
Severity: high Docs Contact:
Priority: high    
Version: 5.0CC: dzickus
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2007-0959 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-07 19:55:21 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:
Bug Depends On: 247561    
Bug Blocks: 311881    
Attachments:
Description Flags
Bugfix.
none
Testcase (`-m32'). none

Description Jan Kratochvil 2007-07-09 08:49:40 UTC
Description of problem:
If you run i386-built GDB on x86_64 system it prints error if its (i386)
inferior starts to use threading (TLS).

Version-Release number of selected component (if applicable):
kernel-2.6.18-8.1.8.el5.x86_64
(kernel-2.6.21-1.3228.fc7.x86_64)

How reproducible:
Always.

Steps to Reproduce:
1. gdb ./threadit # threadit is a simple pthread_create() program.
2. run

Actual results:
(gdb) r
Starting program: /root/jkratoch/redhat/threadit 
warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4
[Thread debugging using libthread_db enabled]
[New Thread -134482240 (LWP 25106)]
thread_get_info_callback: cannot get thread info: generic error
(gdb) _

Expected results:
(gdb) r
Starting program: /root/jkratoch/redhat/threadit 
warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4
[Thread debugging using libthread_db enabled]
[New Thread -134482240 (LWP 25111)]
[New Thread -134485104 (LWP 25114)]
 - running inferior -

Additional info:
Provided a testcase.
It affects RHEL5 + F7 (expecting also F6, untested)
As it is a ptrace(2) bug it is a Regression since RHEL-4.

Testcase run on the F7 (/RHEL5) kernel:
sh-3.2# ./debugreg32 
u_debugreg[0] == 0x0
gs == 0x63
thread_area == 0xf7fc56c0
u_debugreg[0] = 0x01010101
u_debugreg[0] == 0x0
gs == 0x63
thread_area == 0x1010101
debugreg32: debugreg32.c:164: main: Assertion `debugreg0_new == 0x01010101' failed.
Aborted

Testcase run on the kernel with the attached patch:
u_debugreg[0] == 0x0
gs == 0x63
thread_area == 0xf7f1c6c0
u_debugreg[0] = 0x01010101
u_debugreg[0] == 0x1010101
gs == 0x63
thread_area == 0xf7f1c6c0
PASS

Testcase must be built with `-m32':
  gcc -o debugreg32 debugreg32.c -Wall -ggdb2 -pthread -m32
and it provides both the debugger and its inferior as i386 code.

Comment 1 Jan Kratochvil 2007-07-09 08:49:41 UTC
Created attachment 158749 [details]
Bugfix.

Comment 2 Jan Kratochvil 2007-07-09 08:50:28 UTC
Created attachment 158750 [details]
Testcase (`-m32').

Comment 4 Don Zickus 2007-09-18 19:23:54 UTC
in 2.6.18-48.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5

Comment 7 errata-xmlrpc 2007-11-07 19:55:21 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 the 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-2007-0959.html