From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Oleg Nesterov <oleg@tv-sign.ru>,
Roland McGrath <roland@redhat.com>
Subject: Re: [BUG] signal: multithread program returns with wrong errno on receiving SIGSTOP
Date: Tue, 29 May 2007 17:09:37 +0900 [thread overview]
Message-ID: <87646caw5a.wl%takeuchi_satoru@jp.fujitsu.com> (raw)
In-Reply-To: <20070529010315.d6ed6456.akpm@linux-foundation.org>
Hi Andrew,
> What kernel versions is this occurring on?
2.6.22-rc3 is.
Satoru
At Tue, 29 May 2007 01:03:15 -0700,
Andrew Morton wrote:
>
> On Mon, 28 May 2007 11:32:00 +0900 Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> wrote:
>
> > Hi,
> >
> > I found a bug on signal subsystem. If there is some multithread program
> > and one of the thread is blocking on the system call, it returns with
> > wrong errno on receiving SIGSTOP and following SIGCONT.
> >
> > Arch dependency
> > ===============
> >
> > succeed to reproduce: i386, ia64
> > Unknown: any other arch
> >
> > # I suspect that this problem occur on any arch...
> >
> > How to reproduce
> > ================
> >
> > This process needs 2 terminals, term A and term B.
> >
> > 1. issue the test program (attached on this mail) from term A.
> >
> > $ ./mt-wrong-errno
> >
> > 2. send SIGSTOP to test program from term B.
> >
> > $ ps a
> > ...
> > 9685 pts/3 Sl+ 0:00 ./mt-wrong-errno
> > 9688 pts/4 R+ 0:00 ps a
> > $ kill -STOP 9685
> >
> > 3. send SIGCONT to test program from term B.
> >
> > $ kill -CONT 9685
> >
> > Expected Result
> > ===============
> >
> > `./mt-wrong-errno' restarts read syscall (and stop again by receiving
> > SIGTTIN).
> >
> > Actual Result
> > =============
> >
> > `./mt-wrong-errno' returns with wrong errno 512 means ERESTARTSYS.
> > The comment on include/linux/errno.h says "this errno should never be
> > seen by user program." So it's definitely a bug.
> >
> > output of term A
> > ----------------
> >
> > $ ./mt-wrong-errno
> >
> > [1]+ Stopped ./mt-wrong-errno
> > $ errno = 512
> >
> > output of term B
> > ----------------
> >
> > $ ps a
> > ...
> > 9685 pts/3 Sl+ 0:00 ./mt-wrong-errno
> > 9688 pts/4 R+ 0:00 ps a
> > $ kill -STOP 9685
> > $ kill -CONT 9685
> >
> >
> > This problem can always reproduce, so it's no timing issue. I suspect
> > that group_stop_count counting mechanism has something wrong and
> > signal handling is canceled erroneously.
> >
> > Any hints or patch itself are welcome.
> >
> > Thanks,
> >
> > Satoru
> >
> > -------------------------------------------------------------------------------
> > /*
> > * mt-wrong-errno.c
> > *
> > * Copyright 2007 Satoru Takeuchi <takeuchi_satoru@jp.futjisu.com>
> > *
> > * This software may be used and distributed according to the terms
> > * of the GNU General Public License, incorporated herein by reference.
> > *
> > */
> >
> > #include <sys/types.h>
> > #include <pthread.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <err.h>
> > #include <unistd.h>
> > #include <stdio.h>
> > #include <errno.h>
> >
> > void *thread_fn(void *arg)
> > {
> > char c;
> > int ret;
> >
> > ret = read(STDIN_FILENO, &c, 1);
> > if (ret < 0)
> > printf("errno = %d\n", errno);
> >
> > return NULL;
> > }
> >
> > int main(int argc, char *argv[])
> > {
> > pthread_t t;
> >
> > if (pthread_create(&t, NULL, thread_fn, NULL))
> > err(EXIT_FAILURE, "pthread_create() failed\n");
> >
> > if (pthread_join(t, NULL))
> > warn("pthread_join() failed\n");
> > }
>
> What kernel versions is this occurring on?
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2007-05-29 8:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-28 2:32 Satoru Takeuchi
2007-05-29 8:03 ` Andrew Morton
2007-05-29 8:04 ` Roland McGrath
2007-05-29 8:09 ` Satoru Takeuchi [this message]
2007-05-28 7:07 Oleg Nesterov
2007-05-28 9:58 ` Satoru Takeuchi
2007-05-28 10:13 ` Oleg Nesterov
2007-05-29 7:33 ` Roland McGrath
2007-05-29 19:22 ` Oleg Nesterov
2007-05-29 19:28 ` Roland McGrath
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=87646caw5a.wl%takeuchi_satoru@jp.fujitsu.com \
--to=takeuchi_satoru@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--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
all inboxes | Powered by JetHome®