glibc/fix-locking-in-_IO_cleanup.patch

234 lines
6.5 KiB
Diff
Raw Normal View History

Always do locking when accessing streams (bug 15142, bug 14697)
Accepting request 572614 from home:Andreas_Schwab:Factory - Update to glibc 2.27 * Optimized x86-64 asin, atan2, exp, expf, log, pow, atan, sin, cosf, sinf, sincosf and tan with FMA * Optimized x86-64 trunc and truncf for processors with SSE4.1 * Optimized generic expf, exp2f, logf, log2f, powf, sinf, cosf and sincosf * In order to support faster and safer process termination the malloc API family of functions will no longer print a failure address and stack backtrace after detecting heap corruption * The abort function terminates the process immediately, without flushing stdio streams * On platforms where long double has the IEEE binary128 format (aarch64, alpha, mips64, riscv, s390 and sparc), the math library now implements _Float128 interfaces for that type, as defined by ISO/IEC TS 18661-3:2015 These are the same interfaces added in version 2.26 for some platforms where this format is supported but is not the format of long double * On platforms with support for _Float64x (aarch64, alpha, i386, ia64, mips64, powerpc64le, riscv, s390, sparc and x86_64), the math library now implements interfaces for that type, as defined by ISO/IEC TS 18661-3:2015 * The math library now implements interfaces for the _Float32, _Float64 and _Float32x types, as defined by ISO/IEC TS 18661-3:2015 * glibc now implements the memfd_create and mlock2 functions on Linux * Support for memory protection keys was added * The copy_file_range function was added * The ldconfig utility now processes `include' directives using the C/POSIX collation ordering * Support for two grammatical forms of month names has been added * Support for the RISC-V ISA running on Linux has been added * Statically compiled applications attempting to load locales compiled for the OBS-URL: https://build.opensuse.org/request/show/572614 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=491
2018-02-05 11:33:11 +01:00
Now that abort no longer calls fflush there is no reason to avoid locking
the stdio streams anywhere. This fixes a conformance issue and potential
heap corruption during exit.
Index: glibc-2.37/libio/genops.c
===================================================================
--- glibc-2.37.orig/libio/genops.c
+++ glibc-2.37/libio/genops.c
@@ -682,7 +682,7 @@ _IO_adjust_column (unsigned start, const
Accepting request 627715 from home:Andreas_Schwab:Factory - Update to glibc 2.28 * The localization data for ISO 14651 is updated to match the 2016 Edition 4 release of the standard, this matches data provided by Unicode 9.0.0 * Unicode 11.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 11.0.0, using generator scripts contributed by Mike FABIAN (Red Hat) * <math.h> functions that round their results to a narrower type are added from TS 18661-1:2014 and TS 18661-3:2015 * Two grammatical forms of month names are now supported * The renameat2 function has been added, a variant of the renameat function which has a flags argument * The statx function has been added, a variant of the fstatat64 function with an additional flags argument * IDN domain names in getaddrinfo and getnameinfo now use the system libidn2 library if installed * Parsing of dynamic string tokens in DT_RPATH, DT_RUNPATH, DT_NEEDED, DT_AUXILIARY, and DT_FILTER has been expanded to support the full range of ELF gABI expressions including such constructs as '$ORIGIN$ORIGIN' (if valid) * Support for ISO C threads (ISO/IEC 9899:2011) has been added. * The nonstandard header files <libio.h> and <_G_config.h> are no longer installed * The stdio functions 'getc' and 'putc' are no longer defined as macros * All stdio functions now treat end-of-file as a sticky condition * The macros 'major', 'minor', and 'makedev' are now only available from the header <sys/sysmacros.h> * The obsolete function ustat is no longer available to newly linked binaries; the headers <ustat.h> and <sys/ustat.h> have been removed * The obsolete function nfsservctl is no longer available to newly linked OBS-URL: https://build.opensuse.org/request/show/627715 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=509
2018-08-06 17:01:59 +02:00
libc_hidden_def (_IO_adjust_column)
int
-_IO_flush_all_lockp (int do_lock)
+_IO_flush_all (void)
{
int result = 0;
Accepting request 627715 from home:Andreas_Schwab:Factory - Update to glibc 2.28 * The localization data for ISO 14651 is updated to match the 2016 Edition 4 release of the standard, this matches data provided by Unicode 9.0.0 * Unicode 11.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 11.0.0, using generator scripts contributed by Mike FABIAN (Red Hat) * <math.h> functions that round their results to a narrower type are added from TS 18661-1:2014 and TS 18661-3:2015 * Two grammatical forms of month names are now supported * The renameat2 function has been added, a variant of the renameat function which has a flags argument * The statx function has been added, a variant of the fstatat64 function with an additional flags argument * IDN domain names in getaddrinfo and getnameinfo now use the system libidn2 library if installed * Parsing of dynamic string tokens in DT_RPATH, DT_RUNPATH, DT_NEEDED, DT_AUXILIARY, and DT_FILTER has been expanded to support the full range of ELF gABI expressions including such constructs as '$ORIGIN$ORIGIN' (if valid) * Support for ISO C threads (ISO/IEC 9899:2011) has been added. * The nonstandard header files <libio.h> and <_G_config.h> are no longer installed * The stdio functions 'getc' and 'putc' are no longer defined as macros * All stdio functions now treat end-of-file as a sticky condition * The macros 'major', 'minor', and 'makedev' are now only available from the header <sys/sysmacros.h> * The obsolete function ustat is no longer available to newly linked binaries; the headers <ustat.h> and <sys/ustat.h> have been removed * The obsolete function nfsservctl is no longer available to newly linked OBS-URL: https://build.opensuse.org/request/show/627715 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=509
2018-08-06 17:01:59 +02:00
FILE *fp;
@@ -695,8 +695,7 @@ _IO_flush_all_lockp (int do_lock)
Accepting request 627715 from home:Andreas_Schwab:Factory - Update to glibc 2.28 * The localization data for ISO 14651 is updated to match the 2016 Edition 4 release of the standard, this matches data provided by Unicode 9.0.0 * Unicode 11.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 11.0.0, using generator scripts contributed by Mike FABIAN (Red Hat) * <math.h> functions that round their results to a narrower type are added from TS 18661-1:2014 and TS 18661-3:2015 * Two grammatical forms of month names are now supported * The renameat2 function has been added, a variant of the renameat function which has a flags argument * The statx function has been added, a variant of the fstatat64 function with an additional flags argument * IDN domain names in getaddrinfo and getnameinfo now use the system libidn2 library if installed * Parsing of dynamic string tokens in DT_RPATH, DT_RUNPATH, DT_NEEDED, DT_AUXILIARY, and DT_FILTER has been expanded to support the full range of ELF gABI expressions including such constructs as '$ORIGIN$ORIGIN' (if valid) * Support for ISO C threads (ISO/IEC 9899:2011) has been added. * The nonstandard header files <libio.h> and <_G_config.h> are no longer installed * The stdio functions 'getc' and 'putc' are no longer defined as macros * All stdio functions now treat end-of-file as a sticky condition * The macros 'major', 'minor', and 'makedev' are now only available from the header <sys/sysmacros.h> * The obsolete function ustat is no longer available to newly linked binaries; the headers <ustat.h> and <sys/ustat.h> have been removed * The obsolete function nfsservctl is no longer available to newly linked OBS-URL: https://build.opensuse.org/request/show/627715 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=509
2018-08-06 17:01:59 +02:00
for (fp = (FILE *) _IO_list_all; fp != NULL; fp = fp->_chain)
{
run_fp = fp;
- if (do_lock)
- _IO_flockfile (fp);
+ _IO_flockfile (fp);
if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
|| (_IO_vtable_offset (fp) == 0
@@ -706,8 +705,7 @@ _IO_flush_all_lockp (int do_lock)
&& _IO_OVERFLOW (fp, EOF) == EOF)
result = EOF;
- if (do_lock)
- _IO_funlockfile (fp);
+ _IO_funlockfile (fp);
run_fp = NULL;
}
@@ -718,14 +716,6 @@ _IO_flush_all_lockp (int do_lock)
return result;
}
-
-
-int
-_IO_flush_all (void)
-{
- /* We want locking. */
- return _IO_flush_all_lockp (1);
-}
libc_hidden_def (_IO_flush_all)
void
@@ -791,6 +781,9 @@ _IO_unbuffer_all (void)
{
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
int legacy = 0;
+ run_fp = fp;
+ _IO_flockfile (fp);
+
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
if (__glibc_unlikely (_IO_vtable_offset (fp) != 0))
legacy = 1;
@@ -800,18 +793,6 @@ _IO_unbuffer_all (void)
/* Iff stream is un-orientated, it wasn't used. */
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
&& (legacy || fp->_mode != 0))
{
-#ifdef _IO_MTSAFE_IO
- int cnt;
-#define MAXTRIES 2
- for (cnt = 0; cnt < MAXTRIES; ++cnt)
- if (fp->_lock == NULL || _IO_lock_trylock (*fp->_lock) == 0)
- break;
- else
- /* Give the other thread time to finish up its use of the
- stream. */
- __sched_yield ();
-#endif
-
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
if (! legacy && ! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
{
fp->_flags |= _IO_USER_BUF;
@@ -825,17 +806,15 @@ _IO_unbuffer_all (void)
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
if (! legacy && fp->_mode > 0)
_IO_wsetb (fp, NULL, NULL, 0);
-
-#ifdef _IO_MTSAFE_IO
- if (cnt < MAXTRIES && fp->_lock != NULL)
- _IO_lock_unlock (*fp->_lock);
-#endif
}
/* Make sure that never again the wide char functions can be
used. */
Accepting request 720569 from home:Andreas_Schwab:Factory - Update to glibc 2.30 * Unicode 12.1.0 Support * The dynamic linker accepts the --preload argument to preload shared objects * The twalk_r function has been added * On Linux, the getdents64, gettid, and tgkill functions have been added * Minguo (Republic of China) calendar support has been added * The entry for the new Japanese era has been added * Memory allocation functions malloc, calloc, realloc, reallocarray, valloc, pvalloc, memalign, and posix_memalign fail now with total object size larger than PTRDIFF_MAX * The dynamic linker no longer refuses to load objects which reference versioned symbols whose implementation has moved to a different soname since the object has been linked * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait functions * On AArch64 the GNU IFUNC resolver call ABI changed * The copy_file_range function fails with ENOSYS if the kernel does not support the system call of the same name * The functions clock_gettime, clock_getres, clock_settime, clock_getcpuclockid, clock_nanosleep were removed from the librt library for new applications (on architectures which had them) * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed * Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 resolver flag (deprecated in glibc 2.25) have been removed * The obsolete RES_INSECURE1 and RES_INSECURE2 option flags for the DNS stub resolver have been removed from <resolv.h> * With --enable-bind-now, installed programs are now linked with the OBS-URL: https://build.opensuse.org/request/show/720569 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=535
2019-08-02 12:32:26 +02:00
if (! legacy)
fp->_mode = -1;
+
+ _IO_funlockfile (fp);
+ run_fp = NULL;
}
Accepting request 572614 from home:Andreas_Schwab:Factory - Update to glibc 2.27 * Optimized x86-64 asin, atan2, exp, expf, log, pow, atan, sin, cosf, sinf, sincosf and tan with FMA * Optimized x86-64 trunc and truncf for processors with SSE4.1 * Optimized generic expf, exp2f, logf, log2f, powf, sinf, cosf and sincosf * In order to support faster and safer process termination the malloc API family of functions will no longer print a failure address and stack backtrace after detecting heap corruption * The abort function terminates the process immediately, without flushing stdio streams * On platforms where long double has the IEEE binary128 format (aarch64, alpha, mips64, riscv, s390 and sparc), the math library now implements _Float128 interfaces for that type, as defined by ISO/IEC TS 18661-3:2015 These are the same interfaces added in version 2.26 for some platforms where this format is supported but is not the format of long double * On platforms with support for _Float64x (aarch64, alpha, i386, ia64, mips64, powerpc64le, riscv, s390, sparc and x86_64), the math library now implements interfaces for that type, as defined by ISO/IEC TS 18661-3:2015 * The math library now implements interfaces for the _Float32, _Float64 and _Float32x types, as defined by ISO/IEC TS 18661-3:2015 * glibc now implements the memfd_create and mlock2 functions on Linux * Support for memory protection keys was added * The copy_file_range function was added * The ldconfig utility now processes `include' directives using the C/POSIX collation ordering * Support for two grammatical forms of month names has been added * Support for the RISC-V ISA running on Linux has been added * Statically compiled applications attempting to load locales compiled for the OBS-URL: https://build.opensuse.org/request/show/572614 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=491
2018-02-05 11:33:11 +01:00
#ifdef _IO_MTSAFE_IO
@@ -861,9 +840,7 @@ libc_freeres_fn (buffer_free)
int
_IO_cleanup (void)
{
- /* We do *not* want locking. Some threads might use streams but
- that is their problem, we flush them underneath them. */
- int result = _IO_flush_all_lockp (0);
+ int result = _IO_flush_all ();
/* We currently don't have a reliable mechanism for making sure that
C++ static destructors are executed in the correct order.
Index: glibc-2.37/libio/libioP.h
===================================================================
--- glibc-2.37.orig/libio/libioP.h
+++ glibc-2.37/libio/libioP.h
@@ -488,7 +488,6 @@ extern int _IO_new_do_write (FILE *, con
Accepting request 627715 from home:Andreas_Schwab:Factory - Update to glibc 2.28 * The localization data for ISO 14651 is updated to match the 2016 Edition 4 release of the standard, this matches data provided by Unicode 9.0.0 * Unicode 11.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 11.0.0, using generator scripts contributed by Mike FABIAN (Red Hat) * <math.h> functions that round their results to a narrower type are added from TS 18661-1:2014 and TS 18661-3:2015 * Two grammatical forms of month names are now supported * The renameat2 function has been added, a variant of the renameat function which has a flags argument * The statx function has been added, a variant of the fstatat64 function with an additional flags argument * IDN domain names in getaddrinfo and getnameinfo now use the system libidn2 library if installed * Parsing of dynamic string tokens in DT_RPATH, DT_RUNPATH, DT_NEEDED, DT_AUXILIARY, and DT_FILTER has been expanded to support the full range of ELF gABI expressions including such constructs as '$ORIGIN$ORIGIN' (if valid) * Support for ISO C threads (ISO/IEC 9899:2011) has been added. * The nonstandard header files <libio.h> and <_G_config.h> are no longer installed * The stdio functions 'getc' and 'putc' are no longer defined as macros * All stdio functions now treat end-of-file as a sticky condition * The macros 'major', 'minor', and 'makedev' are now only available from the header <sys/sysmacros.h> * The obsolete function ustat is no longer available to newly linked binaries; the headers <ustat.h> and <sys/ustat.h> have been removed * The obsolete function nfsservctl is no longer available to newly linked OBS-URL: https://build.opensuse.org/request/show/627715 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=509
2018-08-06 17:01:59 +02:00
extern int _IO_old_do_write (FILE *, const char *, size_t);
extern int _IO_wdo_write (FILE *, const wchar_t *, size_t);
libc_hidden_proto (_IO_wdo_write)
-extern int _IO_flush_all_lockp (int);
extern int _IO_flush_all (void);
libc_hidden_proto (_IO_flush_all)
extern int _IO_cleanup (void);
Index: glibc-2.37/support/delayed_exit.c
===================================================================
--- glibc-2.37.orig/support/delayed_exit.c
+++ glibc-2.37/support/delayed_exit.c
@@ -23,33 +23,58 @@
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
+#include <support/support.h>
#include <time.h>
+#include <unistd.h>
+
+struct delayed_exit_request
+{
+ void (*exitfunc) (int);
+ int seconds;
+};
static void *
-delayed_exit_thread (void *seconds_as_ptr)
+delayed_exit_thread (void *closure)
{
- int seconds = (uintptr_t) seconds_as_ptr;
- struct timespec delay = { seconds, 0 };
+ struct delayed_exit_request *request = closure;
+ void (*exitfunc) (int) = request->exitfunc;
+ struct timespec delay = { request->seconds, 0 };
struct timespec remaining = { 0 };
+ free (request);
+
if (nanosleep (&delay, &remaining) != 0)
FAIL_EXIT1 ("nanosleep: %m");
/* Exit the process sucessfully. */
- exit (0);
+ exitfunc (0);
return NULL;
}
-void
-delayed_exit (int seconds)
+static void
+delayed_exit_1 (int seconds, void (*exitfunc) (int))
{
/* Create the new thread with all signals blocked. */
sigset_t all_blocked;
sigfillset (&all_blocked);
sigset_t old_set;
xpthread_sigmask (SIG_SETMASK, &all_blocked, &old_set);
+ struct delayed_exit_request *request = xmalloc (sizeof (*request));
+ request->seconds = seconds;
+ request->exitfunc = exitfunc;
/* Create a detached thread. */
- pthread_t thr = xpthread_create
- (NULL, delayed_exit_thread, (void *) (uintptr_t) seconds);
+ pthread_t thr = xpthread_create (NULL, delayed_exit_thread, request);
xpthread_detach (thr);
/* Restore the original signal mask. */
xpthread_sigmask (SIG_SETMASK, &old_set, NULL);
}
+
+void
+delayed_exit (int seconds)
+{
+ delayed_exit_1 (seconds, exit);
+}
+
+void
+delayed__exit (int seconds)
+{
+ delayed_exit_1 (seconds, _exit);
+}
Index: glibc-2.37/support/xthread.h
===================================================================
--- glibc-2.37.orig/support/xthread.h
+++ glibc-2.37/support/xthread.h
@@ -25,11 +25,14 @@
__BEGIN_DECLS
-/* Terminate the process (with exit status 0) after SECONDS have
- elapsed, from a helper thread. The process is terminated with the
- exit function, so atexit handlers are executed. */
+/* Terminate the process (with exit (0)) after SECONDS have elapsed,
+ from a helper thread. The process is terminated with the exit
+ function, so atexit handlers are executed. */
void delayed_exit (int seconds);
+/* Like delayed_exit, but use _exit (0). */
+void delayed__exit (int seconds);
+
/* Returns true if Priority Inheritance support CLOCK_MONOTONIC. */
bool support_mutex_pi_monotonic (void);
Index: glibc-2.37/sysdeps/pthread/tst-stdio1.c
===================================================================
--- glibc-2.37.orig/sysdeps/pthread/tst-stdio1.c
+++ glibc-2.37/sysdeps/pthread/tst-stdio1.c
@@ -46,7 +46,7 @@ do_test (void)
_exit (1);
}
- delayed_exit (1);
+ delayed__exit (1);
xpthread_join (th);
puts ("join returned");