Bug 436183

Summary: utrace: orig_rax 0x00000000ffffffff not recognized as -1
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: kernelAssignee: Roland McGrath <roland>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: kernel-mgr
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-08 20:23:00 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: 434995    
Bug Blocks: 437881, 437882    
Attachments:
Description Flags
GDB workaround created by an ashaming mistake. none

Description Jan Kratochvil 2008-03-05 20:00:57 UTC
Description of problem:
GDB testsuite failure for x86_64 debugger running i386 debuggee.

Version-Release number of selected component (if applicable):
kernel-2.6.25-0.88.rc3.git4.fc9.x86_64 (Rawhide)
but it is OK for: kernel-2.6.23.14-107.fc8.x86_64 (F8)

How reproducible:
Always.

Steps to Reproduce:
1. cd gdb-6.7.1/build-x86_64-redhat-linux-gnu/gdb/testsuite
2. runtest --target_board=unix/-m32 gdb.base/interrupt.exp

Actual results:
Running ../../../gdb/testsuite/gdb.base/interrupt.exp ...
FAIL: gdb.base/interrupt.exp: call function when asleep (stays asleep)
FAIL: gdb.base/interrupt.exp: call function after waking it
FAIL: gdb.base/interrupt.exp: continue
FAIL: gdb.base/interrupt.exp: send end of file

Expected results:
Running ../../../gdb/testsuite/gdb.base/interrupt.exp ...

Additional info:
The problem is that GDB sets orig_rax to 0x00000000ffffffff which gets
recognized by the upstream kernel as -1 but not by the Rawhide kernel.
It is also a regression caused by the fix of the Bug 434995.

Steps to Reproduce:
wget -O erestart-debugger.c
'http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/erestart-debugger.c?cvsroot=systemtap';wget
-O erestart-debuggee.c
'http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/erestart-debuggee.c?cvsroot=systemtap';gcc
-m32 -o erestart-debuggee erestart-debuggee.c -Wall -ggdb2 -D_GNU_SOURCE; gcc
-m64 -o erestart-debugger erestart-debugger.c -Wall -ggdb2 -D_GNU_SOURCE
-lutil;./erestart-debugger ;echo $?

Actual results:
1

Expected results:
0

Comment 1 Jan Kratochvil 2008-03-05 20:03:35 UTC
Created attachment 296924 [details]
GDB workaround created by an ashaming mistake.

Comment 2 Jan Kratochvil 2008-03-05 20:04:16 UTC
Comment on attachment 296924 [details]
GDB workaround created by an ashaming mistake.

Fixing GDB is not a solution as the ptrace-on-utrace emulation should be
backward compatible.

Comment 3 Roland McGrath 2008-03-07 23:09:41 UTC
This is issue is not related to utrace.  It's just x86-64 arch stuff.

In what sense is F8 ok?  AFAICT no x86-64 kernel ever recognized (u32)-1 in
orig_rax as -1.  The botched attempt at syscall restart (i.e. ip -= 2) didn't
happen before because restoring a 32-bit -ERESTART* value was also not
recognized as its proper value (due to lack of sign extension), i.e. bug 434995.

I believe every kernel heretofore has this same problem, and it is only a kernel
with bug 434995 fixed (as rawhide now has) on which you can tell the difference.

I posted a fix upstream: http://marc.info/?l=linux-kernel&m=120493063622563&w=2

I will put it into rawhide too.

Comment 4 Jan Kratochvil 2008-03-08 07:43:59 UTC
Thanks, it looks great; will rerun it on the Rawhide update when available.

You are right x86_64 kernel did not work exactly right but the behavior before 
the Bug 434995 fix behaved IMO more harmless.

Specifically it only printed (and sure aborted the syscall) one
  Unknown error 512
on
  FAIL: gdb.base/interrupt.exp: continue
while currently it hangs much earlier on:
  FAIL: gdb.base/interrupt.exp: call function when asleep (stays asleep)

before the fix:
gdb-6.7.1-15.fc9-kernel-vanilla-2.6.24.1-31.vanilla.fc8.x86_64-target-x86_64/gdb-x86_64-redhat-linux-gnu-m32.sum:
Running ../../../gdb/testsuite/gdb.base/interrupt.exp ...
PASS: gdb.base/interrupt.exp: set interrupt character in interrupt.exp
PASS: gdb.base/interrupt.exp: child process is alive
PASS: gdb.base/interrupt.exp: child process ate our char
PASS: gdb.base/interrupt.exp: send_gdb control C
PASS: gdb.base/interrupt.exp: call function when asleep
PASS: gdb.base/interrupt.exp: call function a second time
FAIL: gdb.base/interrupt.exp: continue (timeout)
FAIL: gdb.base/interrupt.exp: echo data (timeout)
PASS: gdb.base/interrupt.exp: send end of file

after the fix:
gdb-6.7.1-15.fc9-kernel-2.6.25-0.88.rc3.git4.fc9.x86_64-target-x86_64/gdb-x86_64-redhat-linux-gnu-m32.sum:
Running ../../../gdb/testsuite/gdb.base/interrupt.exp ...
PASS: gdb.base/interrupt.exp: set interrupt character in interrupt.exp
PASS: gdb.base/interrupt.exp: child process is alive
PASS: gdb.base/interrupt.exp: child process ate our char
PASS: gdb.base/interrupt.exp: send_gdb control C
FAIL: gdb.base/interrupt.exp: call function when asleep (stays asleep)
FAIL: gdb.base/interrupt.exp: call function after waking it
PASS: gdb.base/interrupt.exp: call function a second time
PASS: gdb.base/interrupt.exp: continue
PASS: gdb.base/interrupt.exp: echo data
FAIL: gdb.base/interrupt.exp: send end of file


Comment 6 Chuck Ebbert 2008-03-08 20:23:00 UTC
Fixed in 2.5.25-rc4-git3

Comment 7 Jan Kratochvil 2008-03-09 06:18:16 UTC
Verified as fixed on:
  kernel-2.6.25-0.101.rc4.git3.fc9.x86_64 (Rawhide)