From: Jesse Allen <the3dfxdude@gmail.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
Mike Hearn <mh@codeweavers.com>, Thomas Sailer <sailer@scs.ch>,
Eric Pouech <pouech-eric@wanadoo.fr>,
Daniel Jacobowitz <dan@debian.org>,
Roland McGrath <roland@redhat.com>,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, wine-devel <wine-devel@winehq.com>
Subject: Re: ptrace single-stepping change breaks Wine
Date: Thu, 30 Dec 2004 12:27:00 -0700 [thread overview]
Message-ID: <53046857041230112742acccbe@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0412300953470.2193@bigblue.dev.mdolabs.com>
On Thu, 30 Dec 2004 09:59:27 -0800 (PST), Davide Libenzi
<davidel@xmailserver.org> wrote:
> On Wed, 29 Dec 2004, Linus Torvalds wrote:
>
> > On Wed, 29 Dec 2004, Davide Libenzi wrote:
> > >
> > > I think same. My test simply let the function processing to let thru and
> > > reach the fake signal sending point.
> >
> > No, your test-case doesn't even send a signal at all, because your
> > test-program just uses a PTRACE_SINGLESTEP without any "send signal" - so
> > "exit_code" will be zero after the debuggee gets released from the
> > "ptrace_notify()", and the suspect code will never be executed..
>
> No no, my test case has nothing to do with the extra signal sent in
> do_syscall_trace(). But the test I put at the time:
>
> - if (!test_thread_flag(TIF_SYSCALL_TRACE))
> + if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
> + !test_thread_flag(TIF_SINGLESTEP))
> return;
>
> will make the code to not execute the "return" (in the single step case)
> and to fall through the point where the signal is sent.
Using the latest version of the patch on do_syscall_trace(), it still
doesn't work unless I remove this test. If indeed it's supposed to
fall through to receive the proper signal, (ie to single step properly
after an int op), then removing it is wrong, and I won't consider it
anymore. I also have to use the patch shown below, with a typo-fixed,
to fix the other problem. I broke it apart from the other because we
might want to consider it seperately right now.
I spent some time speaking to my brother about this. He has done his
own kernel before for an embedded system. He was rather frustrated
with me trying to find a reason for why a rather simple change broke
my program. He told me I couldn't have it both ways. However I
believe that I don't understand the linux code well enough to make
that conclusion.
>
>
> > The problem I think I see (and which the comment alludes to) is that if
> > the controlling process continues the debuggee with a signal, we'll be
> > doing the wrong thing: the code in do_syscall_trace() will take that
> > signal (in "current->exit_code") and send it as a real signal to the
> > debuggee, but since it is debugged, it will be caught (again) by the
> > controlling process, which apparently in the case of Wine gets very
> > confused.
> >
> > So I _think_ the problem happens for the following schenario:
> > - wine for some reason does a PTRACE_SINGLESTEP over a system call
> > - after the single-step, wine ends up trying to get the sub-process to
> > enter a signal handler with ptrace( PTRACE_CONT, ... sig)
> > - the normal ptrace path (where we trap a signal - see kernel/signal.c
> > and the "ptrace_stop()" logic) handles this correctly, but
> > do_syscall_trace() will do a "send_sig()"
> > - we'll try to handle the signal when returning to the traced process
> > - now "get_signal_to_deliver()" will invoce the ptrace logic AGAIN, and
> > call ptrace_stop() for this fake signal, and we'll report a new event
> > to the controlling process.
> >
> > Does this make sense?
>
> This might explain what they were seeing, but OTOH it seems that the real
> cause of their problems is related to something else (according to other
> emails on this thread).
>
>
Actually, I don't think the vanilla kernel has the code that breaks
those other wine programs. I just learned of this yesterday and it's
not related. I believe it's only in fedora core 3 or -ac kernels and
I use vanilla kernels.
Jesse
--- linux/arch/i386/kernel/ptrace.c 2004-12-29 14:10:34.000000000 -0700
+++ linux-mod/arch/i386/kernel/ptrace.c 2004-12-29 20:50:00.000000000 -0700
@@ -142,18 +142,31 @@
{
long eflags;
+ /*
+ * Always set TIF_SINGLESTEP - this guarantees that
+ * we single-step system calls etc..
+ */
set_tsk_thread_flag(child, TIF_SINGLESTEP);
+
+ /*
+ * If TF was already set, don't do anything else
+ */
eflags = get_stack_long(child, EFL_OFFSET);
+ if (eflags & TRAP_FLAG)
+ return;
put_stack_long(child, EFL_OFFSET, eflags | TRAP_FLAG);
child->ptrace |= PT_DTRACE;
}
static void clear_singlestep(struct task_struct *child)
{
+ /* Always clear TIF_SINGLESTEP... */
+ clear_tsk_thread_flag(child, TIF_SINGLESTEP);
+
+ /* But touch TF only if it was set by us.. */
if (child->ptrace & PT_DTRACE) {
long eflags;
- clear_tsk_thread_flag(child, TIF_SINGLESTEP);
eflags = get_stack_long(child, EFL_OFFSET);
put_stack_long(child, EFL_OFFSET, eflags & ~TRAP_FLAG);
child->ptrace &= ~PT_DTRACE;
next prev parent reply other threads:[~2004-12-30 19:27 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.58.0411151439270.2222@ppc970.osdl.org>
2004-11-15 22:53 ` ptrace single-stepping change breaks Wine Roland McGrath
2004-11-19 19:00 ` Eric Pouech
2004-11-19 19:20 ` Linus Torvalds
2004-11-19 19:33 ` Eric Pouech
2004-11-19 19:51 ` Linus Torvalds
2004-11-19 20:41 ` Eric Pouech
2004-11-19 21:22 ` Linus Torvalds
2004-11-19 21:23 ` Daniel Jacobowitz
2004-11-19 21:53 ` Linus Torvalds
2004-11-20 21:49 ` Jesse Allen
2004-11-21 4:55 ` Jesse Allen
2004-11-21 21:32 ` Davide Libenzi
2004-11-21 22:33 ` Linus Torvalds
2004-11-21 23:14 ` Davide Libenzi
2004-11-22 1:12 ` Linus Torvalds
2004-11-22 0:13 ` Andreas Schwab
2004-11-22 1:07 ` Linus Torvalds
2004-11-22 4:06 ` Davide Libenzi
2004-11-22 4:29 ` Linus Torvalds
2004-11-22 6:23 ` Linus Torvalds
2004-11-22 11:06 ` Andreas Schwab
2004-11-22 16:27 ` Linus Torvalds
2004-11-22 13:46 ` Davide Libenzi
2004-11-22 23:15 ` Jesse Allen
2004-11-22 23:48 ` Jesse Allen
2004-11-28 17:01 ` Eric Pouech
2004-11-22 20:52 ` Eric Pouech
2004-11-22 21:10 ` Linus Torvalds
2004-11-22 22:19 ` Mike Hearn
2004-11-22 22:25 ` Linus Torvalds
2004-12-29 2:14 ` Thomas Sailer
2004-12-29 15:02 ` Mike Hearn
2004-12-29 18:53 ` Linus Torvalds
2004-12-29 19:40 ` Jesse Allen
2004-12-29 20:04 ` Linus Torvalds
2004-12-29 21:43 ` Jesse Allen
2004-12-30 0:44 ` Linus Torvalds
2004-12-30 1:13 ` Davide Libenzi
2004-12-30 1:55 ` Linus Torvalds
2004-12-30 4:51 ` Linus Torvalds
2004-12-30 4:58 ` Linus Torvalds
2004-12-30 5:07 ` Davide Libenzi
2004-12-30 7:26 ` Linus Torvalds
2004-12-30 17:59 ` Davide Libenzi
2004-12-30 18:16 ` Linus Torvalds
2004-12-30 19:27 ` Jesse Allen [this message]
2004-12-30 19:34 ` Linus Torvalds
2004-12-30 22:46 ` Linus Torvalds
2004-12-30 23:00 ` Daniel Jacobowitz
2004-12-30 23:17 ` Linus Torvalds
2004-12-31 5:36 ` Daniel Jacobowitz
2004-12-31 5:47 ` Linus Torvalds
2004-12-31 7:00 ` Jesse Allen
2004-12-31 15:10 ` Daniel Jacobowitz
2004-12-31 17:19 ` Linus Torvalds
2005-01-01 23:20 ` Daniel Jacobowitz
2005-01-29 9:25 ` Kari Hurtta
2004-12-30 23:15 ` Andi Kleen
2004-12-31 0:38 ` Linus Torvalds
2004-12-31 12:35 ` Andi Kleen
2004-12-31 15:16 ` Davide Libenzi
2004-12-31 17:30 ` Linus Torvalds
2004-12-31 19:55 ` Jesse Allen
2004-12-31 17:14 ` Linus Torvalds
2004-12-31 4:55 ` Jesse Allen
2004-12-31 5:05 ` Linus Torvalds
2004-12-31 5:38 ` Daniel Jacobowitz
2004-12-30 19:19 ` Davide Libenzi
2004-12-30 5:06 ` Davide Libenzi
2004-12-30 4:28 ` Jesse Allen
2004-12-29 20:56 ` Jesse Allen
2004-12-29 19:35 ` Thomas Sailer
2004-12-29 20:13 ` Jesse Allen
2004-12-30 1:49 ` Thomas Sailer
2004-12-30 2:10 ` Linus Torvalds
2004-12-30 2:39 ` Thomas Sailer
2004-12-30 2:57 ` Thomas Sailer
2004-12-30 3:15 ` Thomas Sailer
2004-12-30 4:15 ` Andrew Morton
2004-12-30 10:09 ` Thomas Sailer
2004-12-30 13:06 ` Mike Hearn
2004-12-31 13:13 ` Thomas Sailer
2004-12-31 13:31 ` Mike Hearn
2004-12-31 15:42 ` Jesse Allen
2004-12-31 15:56 ` Davide Libenzi
2004-12-31 15:59 ` Jesse Allen
2004-12-31 22:01 ` Linus Torvalds
2005-01-01 22:04 ` Davide Libenzi
2005-01-01 22:14 ` Linus Torvalds
2005-01-02 3:46 ` Davide Libenzi
2005-01-07 4:51 ` minor nit with decoding popf instruction - was " John Kacur
2005-01-07 6:48 ` Linus Torvalds
2005-01-08 5:05 ` John Kacur
2004-12-31 15:51 ` Thomas Sailer
[not found] ` <1104873315.3557.87.camel@littlegreen>
2005-01-04 21:21 ` Andrew Morton
2005-01-05 10:43 ` Thomas Sailer
2005-01-05 11:24 ` Ingo Molnar
2005-01-05 11:40 ` Alexandre Julliard
2004-12-30 12:11 ` Mike Hearn
2004-11-20 3:40 ` Roland McGrath
2004-11-19 20:59 ` Grzegorz Kulewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53046857041230112742acccbe@mail.gmail.com \
--to=the3dfxdude@gmail.com \
--cc=akpm@osdl.org \
--cc=dan@debian.org \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mh@codeweavers.com \
--cc=pouech-eric@wanadoo.fr \
--cc=roland@redhat.com \
--cc=sailer@scs.ch \
--cc=torvalds@osdl.org \
--cc=wine-devel@winehq.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox