mailing list of musl libc
 help / color / mirror / code / Atom feed
From: tangyizhou <tangyizhou@huawei.com>
To: "dalias@aerifal.cx" <dalias@aerifal.cx>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>,
	"Wanghui (John)" <john.wanghui@huawei.com>,
	"Huangshuai (OSLab)" <elvis.huang@huawei.com>
Subject: RE: [musl] Fix the return value of pthread_getschedparam in musl libc
Date: Thu, 28 May 2020 14:27:55 +0000	[thread overview]
Message-ID: <4EB7132F5A45D144AC896FC29A83F1920116E2A3@DGGEML501-MBX.china.huawei.com> (raw)
In-Reply-To: <20200522022628.GP1079@brightrain.aerifal.cx>

> There's not such an issue. t->killlock is held so that this can't happen, and more importantly, so that the thread can't exit and the tid be reassigned to a new thread or process that would wrongly be acted upon.

Sorry for late reply.

t->killlock is held only in pthread functions, and it won't work in the following situation.  Assuming process A is running on CPU core 0, process B is running on CPU core 1, process C is running on CPU core 2. Process A calls pthread_getschedparam() to query the information of process B. After SYS_sched_getparam succeeds and before SYS_sched_getscheduler starts,  we assume the scheduling timeslice of A is running out, then A is put in the runqueue of the kernel. This is a chance for C to call kill() to kill B. When A is running again, SYS_sched_getparam returns -ESRCH.

Process B may be terminated due to other reasons when A is put in the runqueue. For example, B is running and encounters a bus error, then B is terminated because of SIGBUS signal.

It very hard to see these situations, but they exist in a theoretical way. There isn't such an issue for the implementation of pthread_getschedparam() of glibc.


Yizhou

  reply	other threads:[~2020-05-28 14:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20  2:09 tangyizhou
2020-05-20 15:50 ` dalias
2020-05-22  1:53   ` tangyizhou
2020-05-22  2:26     ` dalias
2020-05-28 14:27       ` tangyizhou [this message]
2020-05-28 16:09         ` dalias

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=4EB7132F5A45D144AC896FC29A83F1920116E2A3@DGGEML501-MBX.china.huawei.com \
    --to=tangyizhou@huawei.com \
    --cc=dalias@aerifal.cx \
    --cc=elvis.huang@huawei.com \
    --cc=john.wanghui@huawei.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).