From: Oleg Nesterov <oleg@redhat.com>
To: Kaz Kylheku <kkylheku@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Roland McGrath <roland@redhat.com>
Subject: Re: main thread pthread_exit/sys_exit bug!
Date: Tue, 3 Feb 2009 14:33:13 +0100 [thread overview]
Message-ID: <20090203133313.GA5679@redhat.com> (raw)
In-Reply-To: <3f43f78b0902021839j1eb1eb04u49be47277c99900d@mail.gmail.com>
On 02/02, Kaz Kylheku wrote:
>
> On Mon, Feb 2, 2009 at 12:39 PM, Kaz Kylheku <kkylheku@gmail.com> wrote:
> > On Mon, Feb 2, 2009 at 12:17 PM, Ulrich Drepper <drepper@redhat.com> wrote:
> >> The userlevel context of the
> >> thread is not usable anymore. It will have run all kinds of
> >> destructors. The current behavior is AFAIK that the main thread won't
> >> react to any signal anymore. That is absolutely required.
> >
> > Hey Ulrich,
> >
> > Thanks for articulating that requirement. I think it can be met by
> > extending the patch a little bit.
>
> I've now done that.
>
> The exiting thread leader, if there are still other
> threads alive, gets its own private signal handler array in which
> every action is set to SIG_IGN, using the ignore_signals
> function.
>
> I experimented with blocking signals, but that approach
> breaks the test case of being able to attach GDB to the
> exiting thread.
>
> As part of the patch, I found it convenient to extend the
> incomplete sys_unshare functionality w.r.t. signal handlers,
> rather than reinvent the wheel.
This is wrong, we can not and must not unshare ->sighand.
> Cheers ...
>
> http://sourceware.org/bugzilla/attachment.cgi?id=3702
> http://sourceware.org/bugzilla/attachment.cgi?id=3705
This adds multiple problems. Just for example, fs/proc/ takes
leader->sighand->siglock to protect the list of sub-threads.
Of course this doesn't work any longer after unsharing. And
there are numerous similar problems.
ignore_signals() in do_leader_exit() is not right too. This
thread group should hangle the group-wide signals even if
the main thread exits.
atomic_read(&sigh->count) in unshare_sighand() is racy, and
in fact bogus. (yes, the whole unshare_sighand() is bogus,
it never populates new_sighp).
The changing of ->sighand in do_unshare() is very wrong, we
can free the sighand_struct which is currently locked/used/etc.
Kaz, I don't really understand why you are trying to add these
complications to the kernel :(
If the thread exits - it should exit. Yes, we have problems
with the exited main thread, we should fix them.
Yes, gdb refuses to attach to the dead thread (I didn't check
this myself, but I think you are right). But there is nothing
wrong here, because we can't ptrace this thread. But, gdb
_can_ ptrace the process, and it can see it have other threads.
OK, if nothing else. Let's suppose your patch is correct. What
about robust futexes? How can we delay exit_robust_list() ?
I don't think we can.
Oleg.
next prev parent reply other threads:[~2009-02-03 13:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-01 22:32 main thread pthread_exit/sys_exit bug! Kaz Kylheku
[not found] ` <20090201174159.4a52e15c.akpm@linux-foundation.org>
2009-02-02 6:45 ` Oleg Nesterov
2009-02-02 7:10 ` Kaz Kylheku
2009-02-02 16:56 ` Oleg Nesterov
2009-02-02 20:10 ` Kaz Kylheku
2009-02-02 20:17 ` Ulrich Drepper
2009-02-02 20:39 ` Kaz Kylheku
2009-02-03 2:39 ` Kaz Kylheku
2009-02-03 13:33 ` Oleg Nesterov [this message]
2009-02-03 19:51 ` Kaz Kylheku
2009-02-03 21:32 ` Oleg Nesterov
2009-02-03 23:06 ` Kaz Kylheku
2009-02-05 3:05 ` Roland McGrath
2009-02-05 4:55 ` Kaz Kylheku
2009-02-05 16:15 ` Oleg Nesterov
2009-02-05 21:22 ` Roland McGrath
2009-02-05 23:22 ` Oleg Nesterov
2009-02-09 3:33 ` Roland McGrath
2009-02-09 4:52 ` Oleg Nesterov
2009-02-09 5:14 ` Oleg Nesterov
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=20090203133313.GA5679@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=kkylheku@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.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