Commit Graph

516 Commits

Author SHA1 Message Date
Florian Weimer
aae43acfd1 nptl: Move pthread_getspecific, __pthread_getspecific into libc
The symbols have been moved using scripts/move-symbol-to-libc.py.
2021-04-21 19:49:51 +02:00
Florian Weimer
6f009ea984 nptl: Move pthread_key_create, __pthread_key_create into libc
The symbols have been moved using scripts/move-symbol-to-libc.py.
2021-04-21 19:49:51 +02:00
Florian Weimer
75376a3fb8 nptl: Move pthread_setcanceltype into libc
No new symbol version is required because there was a forwarder.

The symbol has been moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
93d78ec1cb nptl: Move pthread_setcancelstate into libc
No new symbol version is required because there was a forwarder.

The symbol has been moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
c62cef023c nptl: Move pthread_exit into libc
The pthread_exit symbol was moved using
scripts/move-symbol-to-libc.py.  No new symbol version is needed
because there was a forwarder.

The new tests nptl/tst-pthread_exit-nothreads and
nptl/tst-pthread_exit-nothreads-static exercise the scenario
that pthread_exit is called without libpthread having been linked in.
This is not possible for the generic code, so these tests do not
live in sysdeps/pthread for now.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
2cfef0b042 nptl: Move __nptl_deallocate_tsd into libc
This prepares moving pthread_exit, and later the pthread_key_create
infrastructure.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
a91bf4e0ff nptl: Move __pthread_keys global variable into libc
This prepares moving pthread_exit, and later the pthread_key_create
infrastructure.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
43fe356d18 nptl: Move internal __nptl_nthreads variable into libc
Reviewed-by: Adhemerval Zanella   <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
1d95b035c7 nptl: Move __pthread_unwind_next into libc
It's necessary to stub out __libc_disable_asynccancel and
__libc_enable_asynccancel via rtld-stubbed-symbols because the new
direct references to the unwinder result in symbol conflicts when the
rtld exception handling from libc is linked in during the construction
of librtld.map.

unwind-forcedunwind.c is merged into unwind-resume.c.  libc now needs
the functions that were previously only used in libpthread.

The GLIBC_PRIVATE exports of __libc_longjmp and __libc_siglongjmp are
no longer needed, so switch them to hidden symbols.

The symbol __pthread_unwind_next has been moved using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
3fec7f18bf nptl: Move pthread_once and __pthread_once into libc
And also the fork generation counter, __fork_generation.  This
eliminates the need for __fork_generation_pointer.

call_once remains in libpthread and calls the exported __pthread_once
symbol.

pthread_once and __pthread_once have been moved using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
4647ce82c7 nptl: Move __pthread_cleanup_upto into libc
This internal symbol is used as part of the longjmp implementation.
Rename the file from nptl/pt-cleanup.c to nptl/pthread_cleanup_upto.c
so that the pt-* files remain restricted to libpthread.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
81dfc6694c nptl: Remove longjmp, siglongjmp from libpthread
The definitions in libc are sufficient, the forwarders are no longer
needed.

The symbols have been moved using scripts/move-symbol-to-libc.py.
s390-linux-gnu and s390x-linux-gnu need a new version placeholder
to keep the GLIBC_2.19 symbol version in libpthread.

Tested on i386-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu,
x86_64-linux-gnu.  Built with build-many-glibcs.py.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
1f2e5bfe48 nptl: Move legacy cancelation handling into libc as compat symbols
This affects _pthread_cleanup_pop, _pthread_cleanup_pop_restore,
_pthread_cleanup_push, _pthread_cleanup_push_defer.  The symbols
have been moved using scripts/move-symbol-to-libc.py.

No new symbol versions are added because the symbols are turned into
compatibility symbols at the same time.

__pthread_cleanup_pop and __pthread_cleanup_push are added as
GLIBC_PRIVATE symbols because they are also used internally, for
glibc's own cancellation handling.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
5715c29e91 nptl: Move __pthread_cleanup_routine into libc
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
f03b78fae4 nptl: Move pthread_mutex_consistent into libc
And deprecated pthread_mutex_consistent_np, its old name.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-04-21 19:49:50 +02:00
Florian Weimer
a64afc2252 nptl_db: Support different libpthread/ld.so load orders (bug 27744)
libthread_db is loaded once GDB encounters libpthread, and at this
point, ld.so may not have been processed by GDB yet. As a result,
_rtld_global cannot be accessed by regular means from libthread_db.
To make this work until GDB can be fixed, acess _rtld_global through
a pointer stored in libpthread.

The new test does not reproduce bug 27744 with
--disable-hardcoded-path-in-tests, but is still a valid smoke test.
With --enable-hardcoded-path-in-tests, it is necessary to avoid
add-symbol-file because this can tickle a GDB bug.

Fixes commit 1daccf403b ("nptl: Move
stack list variables into _rtld_global").

Tested-by: Emil Velikov <emil.velikov@collabora.com>
2021-04-21 11:50:43 +02:00
Adhemerval Zanella
7ab232e081 nptl: Remove unused rules
The wrapper are not exported by libpthread.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
09ce31eddf nptl: Remove __libc_allocate_rtsig, __libc_current_sigrtmax, and __libc_current_sigrtmin
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
70a1e36cbe nptl: Move sigaction to libc
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
ff1e342cd1 nptl: Remove pthread raise implementation
The Linux version already target the current thread by using tgkill
along with getpid and gettid.

For arm, libpthread does not do a intra PLT since it will call the
raise from libc.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
b76658451c nptl: Move pthread_kill to libc
A new 2.34 version is also provided.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
dd10230fd8 nptl: Remove sigsuspend from pthread-compat-wrappers
The symbol is not exported by libpthread.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
ea8966b965 nptl: Remove msgrcv from pthread-compat-wrappers
The symbol is not exported by libpthread.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
8562794d11 nptl: Remove msgsnd from pthread-compat-wrappers
The symbol is not exported by libpthread.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
4c8cb283ec nptl: Remove pwrite from libpthread
The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
dd795c6c24 nptl: Remove pread from libpthread
The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:18 -03:00
Adhemerval Zanella
40873cdd38 nptl: Remove open from libpthread
The libc version is identical and built with same flags.  The libc
version is set as the default version.

Checked on x86_64-linux-gnu.
2021-03-26 13:37:14 -03:00
Adhemerval Zanella
c5c3588475 nptl: Remove lseek from libpthread
The libc version is identical and built with same flags.  The libc
version is set as the default version.

The libpthread compat symbol requires to mask it when building the
loader object otherwise ld might complain about a missing
versioned symbol (as for alpha).

Checked on x86_64-linux-gnu.
2021-03-26 13:36:17 -03:00
Adhemerval Zanella
78d1724d53 nptl: Remove send from libpthread
The libc version is identical and built with same flags.  Both aarch64
and nios2 also requires to export __send and tt was done previously with
the HAVE_INTERNAL_SEND_SYMBOL (which forced the symbol creation).

All __send callers are internal to libc and the original issue that
required the symbol export was due a missing libc_hidden_def.  So
a compat symbol is added for __send and the libc_hidden_def is
defined regardless.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-03-26 13:36:17 -03:00
Adhemerval Zanella
a894053318 signal: Add __libc_sigaction
The generic implementation basically handle the system agnostic logic
(filtering out the invalid signals) while the __libc_sigaction is
the function with implements the system and architecture bits.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
d5ddd583da nptl: Move system to libc
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
9cf242997d nptl: Move fcntl from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
729cb5a2a7 nptl: Remove sendmsg from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
0cf67de816 nptl: Remove recvmsg from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
2d6f4ebd65 nptl: Remove sigwait from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
1e157b9cb4 nptl: Remove tcdrain from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
c29386fd50 nptl: Remove pause from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
0c9d4925fe nptl: Remove msync from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
fc495dc4e9 nptl: Remove fsync from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
6f2e00cac5 nptl: Remove sendto from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
643a88a9c1 nptl: Remove recvfrom from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
494c3beec9 nptl: Remove recv from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
3ddf9bc185 nptl: Remove connect from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:39 -03:00
Adhemerval Zanella
c59f716993 nptl: Remove accept from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:38 -03:00
Adhemerval Zanella
bdfed2e2cd nptl: Remove close from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 15:54:24 -03:00
Adhemerval Zanella
baab50cfb9 nptl: Remove read from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 08:21:29 -03:00
Adhemerval Zanella
173e0ab081 nptl: Remove write from libpthread
The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.
2021-03-18 08:20:43 -03:00
Adhemerval Zanella
7384193b71 nptl: Move fork into libc
This is part of the libpthread removal project:

   <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Checked on x86_64-linux-gnu.
2021-03-12 10:19:58 -03:00
Adhemerval Zanella
2b47727c68 posix: Consolidate register-atfork
Both htl and nptl uses a different data structure to implement atfork
handlers.  The nptl one was refactored by 27761a1042 to use a dynarray
which simplifies the code.

This patch moves the nptl one to be the generic implementation and
replace Hurd linked one.  Different than previous NPTL, Hurd also uses
a global lock, so performance should be similar.

Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for
i686-gnu.
2021-03-12 10:19:22 -03:00
Jakub Jelinek
f0419e6a10 [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
This is another attempt at making pthread_once handle throwing exceptions
from the init routine callback.  As the new testcases show, just switching
to the cleanup attribute based cleanup does fix the tst-once5 test, but
breaks the new tst-oncey3 test.  That is because when throwing exceptions,
only the unwind info registered cleanups (i.e. C++ destructors or cleanup
attribute), when cancelling threads and there has been unwind info from the
cancellation point up to whatever needs cleanup both unwind info registered
cleanups and THREAD_SETMEM (self, cleanup, ...) registered cleanups are
invoked, but once we hit some frame with no unwind info, only the
THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked.
So, to stay fully backwards compatible (allow init routines without
unwind info which encounter cancellation points) and handle exception throwing
we actually need to register the pthread_once cleanups in both unwind info
and in the THREAD_SETMEM (self, cleanup, ...) way.
If an exception is thrown, only the former will happen and we in that case
need to also unregister the THREAD_SETMEM (self, cleanup, ...) registered
handler, because otherwise after catching the exception the user code could
call deeper into the stack some cancellation point, get cancelled and then
a stale cleanup handler would clobber stack and probably crash.
If a thread calling init routine is cancelled and unwind info ends before
the pthread_once frame, it will be cleaned up through self->cleanup as
before.  And if unwind info is present, unwind_stop first calls the
self->cleanup registered handler for the frame, then it will call the
unwind info registered handler but that will already see __do_it == 0
and do nothing.
2021-03-04 15:15:33 +01:00