From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14713 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: changdiankang Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] time: Fix bug in timer_create Date: Tue, 24 Sep 2019 11:16:41 +0000 Message-ID: <5114FFD1D7758546892A923CB3078CD4121624A3@dggemi523-mbx.china.huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_5114FFD1D7758546892A923CB3078CD4121624A3dggemi523mbxchi_" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="116711"; mail-complaints-to="usenet@blaine.gmane.org" To: "musl@lists.openwall.com" Original-X-From: musl-return-14729-gllmg-musl=m.gmane.org@lists.openwall.com Tue Sep 24 13:32:59 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iCj3z-000UAY-LS for gllmg-musl@m.gmane.org; Tue, 24 Sep 2019 13:32:59 +0200 Original-Received: (qmail 30085 invoked by uid 550); 24 Sep 2019 11:32:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 22445 invoked from network); 24 Sep 2019 11:17:32 -0000 Thread-Topic: [PATCH] time: Fix bug in timer_create Thread-Index: AdVyxnWltloN0MggQtK3pbYOvwmaDQ== Accept-Language: en-US Content-Language: zh-CN x-originating-ip: [10.184.194.148] X-CFilter-Loop: Reflected Xref: news.gmane.org gmane.linux.lib.musl.general:14713 Archived-At: --_000_5114FFD1D7758546892A923CB3078CD4121624A3dggemi523mbxchi_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable time: Fix bug in timer_create When create a SIGEV_THREAD timer, in helper thread "start", "id" is assigned with self->timer_id immediately after pthread_create. But the real timer_id is assigned to self->timer_id after SYS_timer_create. So "id" in "start" always be 0, and timer_delete will always fail. Put assignement of "id" after pthread_barrier_wait can fix this bug. Signed-off-by: Chang Diankang > diff --git a/src/time/timer_create.c b/src/time/timer_create.c index c5e40a1..4172b9e 100644 --- a/src/time/timer_create.c +++ b/src/time/timer_create.c @@ -48,13 +48,14 @@ static void *start(void *arg) { pthread_t self =3D __pthread_self(); struct start_args *args =3D arg; - int id =3D self->timer_id; + int id; jmp_buf jb; void (*notify)(union sigval) =3D args->sev->sigev_notify_function; union sigval val =3D args->sev->sigev_value; pthread_barrier_wait(&args->b); + id =3D self->timer_id; for (;;) { siginfo_t si; while (sigwaitinfo(SIGTIMER_SET, &si) < 0); --_000_5114FFD1D7758546892A923CB3078CD4121624A3dggemi523mbxchi_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

time: Fix bug in timer_create

 

When create a SIGEV_THREAD timer, in helper thread &= quot;start",

"id" is assigned with self->timer_id im= mediately after pthread_create.

But the real timer_id is assigned to self->timer_= id after SYS_timer_create.

So "id" in "start" always be 0, = and timer_delete will always fail.

Put assignement of "id" after pthread_barr= ier_wait can fix this bug.

 

Signed-off-by: Chang Diankang <changdiankang@huawei.com>

 

diff --git a/src/time/timer_create.c b/src/time/time= r_create.c

index c5e40a1..4172b9e 100644

--- a/src/time/timer_create.c

+++ b/src/time/timer_create.c=

@@ -48,13 +48,14 @@ static void *start(void *arg= )

{

        pthread_t= self =3D __pthread_self();

        struct st= art_args *args =3D arg;

-       int id =3D sel= f->timer_id;

+       int id;

        jmp_buf j= b;

 

        void (*no= tify)(union sigval) =3D args->sev->sigev_notify_function;<= /p>

        union sig= val val =3D args->sev->sigev_value;

 

        pthread_b= arrier_wait(&args->b);

+       id =3D sel= f->timer_id;

        for (;;) = {

        &nbs= p;       siginfo_t si;

        &nbs= p;       while (sigwaitinfo(SIGTIMER_SET, &am= p;si) < 0);

 

--_000_5114FFD1D7758546892A923CB3078CD4121624A3dggemi523mbxchi_--