This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/15765] sem_open is wrongly a cancellation point
- From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 15 Sep 2016 14:16:05 +0000
- Subject: [Bug nptl/15765] sem_open is wrongly a cancellation point
- Auto-submitted: auto-generated
- References: <bug-15765-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=15765
--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via fbc994921b459d57b681a926780933a20745edf5 (commit)
via 47677f2edc815e85d0383a89b09733e95e5d7302 (commit)
via 49ad334ab10671dabb40eda8beba887ef902f0f3 (commit)
via 91dd866ff1801b27e1db1e14a52eb89a213627e6 (commit)
via 980d25d53e748abd3365aeec0a1ccd1316b4e6d6 (commit)
from 80d8cb91dee8bdcc4e430b3e2620d95f89b1ee0b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fbc994921b459d57b681a926780933a20745edf5
commit fbc994921b459d57b681a926780933a20745edf5
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Aug 22 10:31:42 2016 -0300
rt: Set shm_open as a non cancellation point (BZ #18243)
This patch changes shm_open to not act as a cancellation point.
Cancellation is disable at start and reenable in function exit.
It fixes BZ #18243.
Tested on x86_64 and i686.
[BZ #18243]
* rt/Makefile (test): Add tst-shm-cancel.
* rt/tst-shm-cancel.c: New file.
* sysdeps/posix/shm_open.c: Disable asynchronous cancellation.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=47677f2edc815e85d0383a89b09733e95e5d7302
commit 47677f2edc815e85d0383a89b09733e95e5d7302
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Aug 22 09:39:46 2016 -0300
nptl: Fix sem_wait and sem_timedwait cancellation (BZ#18243)
This patch fixes both sem_wait and sem_timedwait cancellation point for
uncontended case. In this scenario only atomics are involved and thus
the futex cancellable call is not issue and a pending cancellation signal
is not handled.
The fix is straighforward by calling pthread_testcancel is both function
start. Although it would be simpler to call CANCELLATION_P directly, I
decided to add an internal pthread_testcancel alias and use it to export
less internal implementation on such function. A possible change on
how pthread_testcancel is internally implemented would lead to either
continue to force use CANCELLATION_P or to adjust its every use.
GLIBC testcase also does have tests for uncontended cases, test-cancel12
and test-cancel14.c, however both are flawed by adding another
cancellation point just after thread pthread_cleanup_pop:
47 static void *
48 tf (void *arg)
49 {
50 pthread_cleanup_push (cleanup, NULL);
51
52 int e = pthread_barrier_wait (&bar);
53 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
54 {
55 puts ("tf: 1st barrier_wait failed");
56 exit (1);
57 }
58
59 /* This call should block and be cancelable. */
60 sem_wait (&sem);
61
62 pthread_cleanup_pop (0);
63
64 puts ("sem_wait returned");
65
66 return NULL;
67 }
So sem_{timed}wait does not act on cancellation, pthread_cleanup_pop
executes
'cleanup' and then 'puts' acts on cancellation. Since pthread_cleanup_pop
removed the clean-up handler, it will ran only once and thus it won't
accuse
an error to indicate sem_wait has not acted on the cancellation signal.
This patch also fixes this behavior by removing the cancellation point
'puts'.
It also adds some cleanup on all sem_{timed}wait cancel tests.
It partially fixes BZ #18243. Checked on x86_64.
[BZ #18243]
* nptl/pthreadP.h (__pthread_testcancel): Add prototype and
hidden_proto.
* nptl/pthread_testcancel.c (pthread_cancel): Add internal aliais
definition.
* nptl/sem_timedwait.c (sem_timedwait): Add cancellation check for
uncontended case.
* nptl/sem_wait.c (__new_sem_wait): Likewise.
* nptl/tst-cancel12.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel13.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel14.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
* nptl/tst-cancel15.c (cleanup): Remove wrong cancellation point.
(tf): Fix check for uncontended case.
(do_test): Likewise.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=49ad334ab10671dabb40eda8beba887ef902f0f3
commit 49ad334ab10671dabb40eda8beba887ef902f0f3
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Sun Aug 21 17:14:35 2016 -0300
nptl: Remove sparc sem_wait
This patch removes the sparc32 sem_wait.c implementation since it is
identical to default nptl one. The sparcv9 is no longer required with
the removal.
Checked with a sparcv9 build.
* sysdeps/sparc/sparc32/sem_wait.c: Remove file.
* sysdeps/sparc/sparc32/sparcv9/sem_wait.c: Likewise.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=91dd866ff1801b27e1db1e14a52eb89a213627e6
commit 91dd866ff1801b27e1db1e14a52eb89a213627e6
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Sat Aug 20 11:23:08 2016 -0300
nptl: Set sem_open as a non cancellation point (BZ #15765)
This patch changes sem_open to not act as a cancellation point.
Cancellation is disable at start and reenable in function exit.
It fixes BZ #15765.
Tested on x86_64 and i686.
[BZ #15765]
* nptl/Makefile (tests): Add tst-sem16.
* nptl/tst-sem16.c: New file.
* nptl/sem_open.c (sem_open): Disable asynchronous cancellation.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=980d25d53e748abd3365aeec0a1ccd1316b4e6d6
commit 980d25d53e748abd3365aeec0a1ccd1316b4e6d6
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Aug 19 15:30:01 2016 -0300
nptl: Consolidate sem_open implementations
Current sparc32 sem_open and default one only differ on:
1. Default one contains a 'futex_supports_pshared' check.
2. sem.newsem.pad is initialized to zero.
This patch removes sparc32 and sparc32v9 sem_open arch specific
implementation and instead set sparc32 to use nptl default one.
Using 1. is fine since it should always evaluate 0 for Linux
(an optimized away by the compiler). Adding 2. to default
implementation should be ok since 'pad' field is used mainly
on sparc32 code.
I checked on i686 and checked a sparc32v9 build.
* nptl/sem_open.c (sem_open): Init pad value to 0.
* sysdeps/sparc/sparc32/sem_open.c: Remove file.
* sysdeps/sparc/sparc32/sparcv9/sem_open.c: Likewise.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 39 ++++
nptl/Makefile | 2 +-
nptl/pthreadP.h | 2 +
nptl/pthread_testcancel.c | 4 +-
nptl/sem_open.c | 27 +++-
nptl/sem_timedwait.c | 3 +
nptl/sem_wait.c | 13 ++
nptl/tst-cancel12.c | 29 ++--
nptl/tst-cancel13.c | 23 +--
nptl/tst-cancel14.c | 17 +-
nptl/tst-cancel15.c | 23 +--
nptl/tst-sem16.c | 130 +++++++++++++
rt/Makefile | 2 +-
rt/tst-shm-cancel.c | 130 +++++++++++++
sysdeps/posix/shm_open.c | 7 +
sysdeps/sparc/sparc32/sem_open.c | 300 ------------------------------
sysdeps/sparc/sparc32/sem_wait.c | 93 ---------
sysdeps/sparc/sparc32/sparcv9/sem_open.c | 1 -
sysdeps/sparc/sparc32/sparcv9/sem_wait.c | 1 -
19 files changed, 393 insertions(+), 453 deletions(-)
create mode 100644 nptl/tst-sem16.c
create mode 100644 rt/tst-shm-cancel.c
delete mode 100644 sysdeps/sparc/sparc32/sem_open.c
delete mode 100644 sysdeps/sparc/sparc32/sem_wait.c
delete mode 100644 sysdeps/sparc/sparc32/sparcv9/sem_open.c
delete mode 100644 sysdeps/sparc/sparc32/sparcv9/sem_wait.c
--
You are receiving this mail because:
You are on the CC list for the bug.