All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Philippe Gerum <rpm@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] t_suspend and XNBREAK
Date: Tue, 22 Oct 2013 16:49:32 +0200	[thread overview]
Message-ID: <5266907C.4010905@xenomai.org> (raw)
In-Reply-To: <526681B9.1010302@xenomai.org>

On 10/22/2013 03:46 PM, Philippe Gerum wrote:
> On 10/21/2013 08:21 PM, Daniel Merrill wrote:
>
>> More follow up on this, we went ahead and put some logging in shadow.c
>> which from what we could find is where the signal is "kicking" the thread.
>> >From the logging it looks like the only signals we get (while attached to
>> GDB) are SIGSTOP, SIGTRAP, SIGRT32 and SIGKILL(upon exiting the debugger).
>> I'm assuming the SIGSTOP, SIGTRAP and SIGKILL are normal from the
>> debugger. It looks like shadow.c looks for SIGTRAP and SIGSTOP and sets an
>> XNDEBUG state on the thread which I assume allows it to restart the
>> suspend?
>
> XNDEBUG marks a thread which is ptraced, this has implications when
> managing the system timer while the app is single-stepped/stopped by a
> debugger.
>
>    SIGRT32 I believe comes from our calls to t_delete. I'm guessing
>> this is what's causing the suspends to fail? Anyway, I appreciate any
>> additional insight anyone can offer. Thanks again for all the help.
>>
>
> t_delete() will cause t_suspend() to unblock if sent to the suspended
> task, due to receiving SIGRT32/SIGCANCEL from the linux side, which is
> how the NPTL deals with async cancellation internally (t_delete() ->
> pthread_cancel() -> t(g)kill(SIGCANCEL)).
>
> Internally, XNBREAK will be raised for that task, causing -EINTR to be
> propagated back. However, since there is SIGCANCEL pending for the task,
> the NPTL handler should run on the way back to the call site in
> t_suspend(), and the task should never return from this handler.
>
> In short, receiving EINTR from t_suspend() is unexpected, particularly
> when unblocked by SIGCANCEL. I could not reproduce this issue based on
> the simple test, running over GDB (7.5.1).
>
> A few questions more:
>
> - regardless of t_delete(), is the problem about one or multiple threads
> unblocking unexpectedly from t_suspend(0), when single-stepping a
> distinct thread over GDB?
>
> - I'm testing with Xenomai 2.6.3. Which version have you been using, on
> which cpu/platform, using which I-pipe release in the kernel (check
> /proc/xenomai/{version, hal}?
>
> - Also could you write a simple test code illustrating the issue so that
> I could try reproducing it? Typically, would this be reproducible on
> your setup with a single task running t_suspend(0), while ptracing the
> main routine in parallel?

Maybe cancellation is disabled with pthread_setcancelstate?

-- 
					    Gilles.


  reply	other threads:[~2013-10-22 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 16:29 [Xenomai] t_suspend and XNBREAK Daniel Merrill
2013-10-09 16:33 ` Philippe Gerum
2013-10-09 16:37   ` Daniel Merrill
2013-10-09 16:43     ` Philippe Gerum
2013-10-09 17:01       ` Daniel Merrill
2013-10-16 18:30         ` Daniel Merrill
2013-10-21 18:21           ` Daniel Merrill
2013-10-22 13:46             ` Philippe Gerum
2013-10-22 14:49               ` Gilles Chanteperdrix [this message]
2013-10-22 16:53                 ` Philippe Gerum
2013-10-22 22:10                   ` Daniel Merrill
2013-10-23 17:31                     ` Philippe Gerum
2013-10-23 23:11                       ` Daniel Merrill
2013-10-24 10:03                         ` Philippe Gerum
2013-10-24 15:52                           ` Daniel Merrill
2013-10-24 18:24                           ` Daniel Merrill
2013-10-22 16:50               ` Daniel Merrill
2014-05-20 12:52           ` Philippe Gerum

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=5266907C.4010905@xenomai.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=rpm@xenomai.org \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.