diff --git a/common/shlibs b/common/shlibs index 87e6df76f6..bcfec1b377 100644 --- a/common/shlibs +++ b/common/shlibs @@ -17,36 +17,36 @@ # one (order top->bottom) is preferred over the next ones. # libc.so musl-0.9.9_1 -libc.so.6 glibc-2.26_1 -libm.so.6 glibc-2.26_1 -libpthread.so.0 glibc-2.26_1 -librt.so.1 glibc-2.26_1 -libdl.so.2 glibc-2.26_1 -ld-linux-x86-64.so.2 glibc-2.26_1 x86_64 -ld-linux.so.2 glibc-2.26_1 i686 -ld-linux.so.3 glibc-2.26_1 armv5tel -ld-linux-aarch64.so.1 glibc-2.26_1 aarch64 -ld.so.1 glibc-2.26_1 mips -ld-linux-armhf.so.3 glibc-2.26_1 -libresolv.so.2 glibc-2.26_1 -libanl.so.1 glibc-2.26_1 -libthread_db.so.1 glibc-2.26_1 -libutil.so.1 glibc-2.26_1 -libnsl.so.1 glibc-2.26_1 -libnss_db.so.2 glibc-2.26_1 -libnss_files.so.2 glibc-2.26_1 -libnss_compat.so.2 glibc-2.26_1 -libnss_dns.so.2 glibc-2.26_1 -libnss_hesiod.so.2 glibc-2.26_1 -libnss_nisplus.so.2 glibc-2.26_1 -libnss_nis.so.2 glibc-2.26_1 -libcrypt.so.1 glibc-2.26_1 -libBrokenLocale.so.1 glibc-2.26_1 -libmemusage.so glibc-2.26_1 -libSegFault.so glibc-2.26_1 -libpcprofile.so glibc-2.26_1 -libcidn.so.1 glibc-2.26_1 -libmvec.so.1 glibc-2.26_1 +libc.so.6 glibc-2.28_1 +libm.so.6 glibc-2.28_1 +libpthread.so.0 glibc-2.28_1 +librt.so.1 glibc-2.28_1 +libdl.so.2 glibc-2.28_1 +ld-linux-x86-64.so.2 glibc-2.28_1 x86_64 +ld-linux.so.2 glibc-2.28_1 i686 +ld-linux.so.3 glibc-2.28_1 armv5tel +ld-linux-aarch64.so.1 glibc-2.28_1 aarch64 +ld.so.1 glibc-2.28_1 mips +ld-linux-armhf.so.3 glibc-2.28_1 +libresolv.so.2 glibc-2.28_1 +libanl.so.1 glibc-2.28_1 +libthread_db.so.1 glibc-2.28_1 +libutil.so.1 glibc-2.28_1 +libnsl.so.1 glibc-2.28_1 +libnss_db.so.2 glibc-2.28_1 +libnss_files.so.2 glibc-2.28_1 +libnss_compat.so.2 glibc-2.28_1 +libnss_dns.so.2 glibc-2.28_1 +libnss_hesiod.so.2 glibc-2.28_1 +libnss_nisplus.so.2 glibc-2.28_1 +libnss_nis.so.2 glibc-2.28_1 +libcrypt.so.1 glibc-2.28_1 +libBrokenLocale.so.1 glibc-2.28_1 +libmemusage.so glibc-2.28_1 +libSegFault.so glibc-2.28_1 +libpcprofile.so glibc-2.28_1 +libcidn.so.1 glibc-2.28_1 +libmvec.so.1 glibc-2.28_1 libz.so.1 zlib-1.2.3_1 libbz2.so.1 bzip2-1.0.5_1 libarchive.so.13 libarchive-3.1.2_1 diff --git a/srcpkgs/glibc/patches/glibc-upstream-01.patch b/srcpkgs/glibc/patches/glibc-upstream-01.patch index affcee1849..257e5a14ba 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-01.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-01.patch @@ -1,58 +1,40 @@ -From dc258ce62ae0bbb456c6a855dbb6b384ecf7e988 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Thu, 3 Aug 2017 13:59:17 +0200 -Subject: [PATCH 01] getaddrinfo: Release resolver context on error in - gethosts [BZ #21885] +From 7f11842e7483da7aa9fa3031be122021978ef600 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault +Date: Wed, 8 Aug 2018 01:55:04 +0200 +Subject: [PATCH 01] hurd: Add missing symbols for proper + libc_get/setspecific -(cherry picked from commit 964263bb8d650f1681665c55704fb01a8e725621) + * htl/Versions (__pthread_getspecific, __pthread_setspecific): Add + symbols. --- - ChangeLog | 6 ++++++ - NEWS | 6 ++++++ - sysdeps/posix/getaddrinfo.c | 2 ++ - 3 files changed, 14 insertions(+) + ChangeLog | 5 +++++ + htl/Versions | 2 ++ + 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog -index 8dbfc7eaff..28ce9c8479 100644 +index 08b42bd2f5..31abb116a5 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-03 Florian Weimer +@@ -1,3 +1,8 @@ ++2018-08-08 Samuel Thibault + -+ [BZ #21885] -+ * sysdeps/posix/getaddrinfo.c (gethosts): Release resolver context -+ on memory allocation failure. ++ * htl/Versions (__pthread_getspecific, __pthread_setspecific): Add ++ symbols. + - 2017-08-02 Siddhesh Poyarekar + 2018-08-01 Carlos O'Donel - * version.h (RELEASE): Set to "stable" -diff --git a/NEWS b/NEWS -index 8295f20c0a..9a64579658 100644 ---- a/NEWS -+++ b/NEWS -@@ -5,6 +5,12 @@ See the end for copying conditions. - Please send GNU C library bug reports via - using `glibc' in the "product" field. - -+Version 2.26.1 -+ -+The following bugs are resolved with this release: -+ -+ [21885] getaddrinfo: Release resolver context on error in gethosts -+ - Version 2.26 - - Major new features: -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index efa7118498..699411cc92 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -255,6 +255,8 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - break; \ - if (!scratch_buffer_grow (tmpbuf)) \ - { \ -+ __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); \ -+ __resolv_context_put (res_ctx); \ - result = -EAI_MEMORY; \ - goto free_and_return; \ - } \ + * version.h (RELEASE): Set to "stable". +diff --git a/htl/Versions b/htl/Versions +index 6a63a1b8a1..c5a616da10 100644 +--- a/htl/Versions ++++ b/htl/Versions +@@ -150,6 +150,8 @@ libpthread { + __cthread_keycreate; + __cthread_getspecific; + __cthread_setspecific; ++ __pthread_getspecific; ++ __pthread_setspecific; + __pthread_getattr_np; + __pthread_attr_getstack; + } diff --git a/srcpkgs/glibc/patches/glibc-upstream-02.patch b/srcpkgs/glibc/patches/glibc-upstream-02.patch index 583b9a0825..0a38562479 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-02.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-02.patch @@ -1,77 +1,63 @@ -From 665ce88d68fd13c5c4cbaf2808434c618745137c Mon Sep 17 00:00:00 2001 -From: Aurelien Jarno -Date: Thu, 3 Aug 2017 22:33:19 +0000 -Subject: [PATCH 02] i686/multiarch: Regenerate ulps -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +From 726e1554ce4db5e35af41cb0110c54c5e1232054 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault +Date: Thu, 9 Aug 2018 01:26:19 +0200 +Subject: [PATCH 02] hurd: Avoid PLTs for __pthread_get/setspecific -This comes from running “make regen-ulps” on an AMD Opteron 2378 CPU. - -Changelog: - * sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Regenerated. -(cherry picked from commit 144bdab050bdd78c327d98a79b15c5b164e1d56f) +* sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific, +__pthread_setspecific): Add hidden proto. +* sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def. +* sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def. --- - ChangeLog | 4 ++++ - sysdeps/i386/i686/fpu/multiarch/libm-test-ulps | 14 +++++++------- - 2 files changed, 11 insertions(+), 7 deletions(-) + ChangeLog | 4 ++++ + sysdeps/htl/pt-getspecific.c | 1 + + sysdeps/htl/pt-setspecific.c | 1 + + sysdeps/htl/pthreadP.h | 2 ++ + 4 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog -index 28ce9c8479..3478699b10 100644 +index 31abb116a5..dbcc56667b 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,7 @@ -+2017-08-03 Aurelien Jarno -+ -+ * sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Regenerated. -+ - 2017-08-03 Florian Weimer +@@ -2,6 +2,10 @@ - [BZ #21885] -diff --git a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps -index 81dd1a09ea..053f5ec972 100644 ---- a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps -+++ b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps -@@ -58,7 +58,7 @@ double: 1 - float128: 2 - idouble: 1 - ifloat128: 2 --ildouble: 4 -+ildouble: 5 - ldouble: 3 + * htl/Versions (__pthread_getspecific, __pthread_setspecific): Add + symbols. ++ * sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific, ++ __pthread_setspecific): Add hidden proto. ++ * sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def. ++ * sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def. - Function: "asin": -@@ -1154,8 +1154,8 @@ float128: 4 - idouble: 3 - ifloat: 3 - ifloat128: 4 --ildouble: 7 --ldouble: 7 -+ildouble: 8 -+ldouble: 8 + 2018-08-01 Carlos O'Donel - Function: Imaginary part of "clog10_upward": - double: 1 -@@ -2013,8 +2013,8 @@ double: 3 - float: 4 - idouble: 3 - ifloat: 4 --ildouble: 5 --ldouble: 5 -+ildouble: 6 -+ldouble: 6 +diff --git a/sysdeps/htl/pt-getspecific.c b/sysdeps/htl/pt-getspecific.c +index a0227a67f6..64ddf9551a 100644 +--- a/sysdeps/htl/pt-getspecific.c ++++ b/sysdeps/htl/pt-getspecific.c +@@ -36,3 +36,4 @@ __pthread_getspecific (pthread_key_t key) + return self->thread_specifics[key]; + } + strong_alias (__pthread_getspecific, pthread_getspecific); ++hidden_def (__pthread_getspecific) +diff --git a/sysdeps/htl/pt-setspecific.c b/sysdeps/htl/pt-setspecific.c +index a46a12f157..02aff417ef 100644 +--- a/sysdeps/htl/pt-setspecific.c ++++ b/sysdeps/htl/pt-setspecific.c +@@ -48,3 +48,4 @@ __pthread_setspecific (pthread_key_t key, const void *value) + return 0; + } + strong_alias (__pthread_setspecific, pthread_setspecific); ++hidden_def (__pthread_setspecific) +diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h +index 132ac1718e..71c2fcd9c6 100644 +--- a/sysdeps/htl/pthreadP.h ++++ b/sysdeps/htl/pthreadP.h +@@ -68,6 +68,8 @@ struct __pthread_cancelation_handler **___pthread_get_cleanup_stack (void) attri - Function: "hypot": - double: 1 -@@ -2205,8 +2205,8 @@ float128: 8 - idouble: 3 - ifloat: 4 - ifloat128: 8 --ildouble: 5 --ldouble: 5 -+ildouble: 6 -+ldouble: 6 + #if IS_IN (libpthread) + hidden_proto (__pthread_key_create) ++hidden_proto (__pthread_getspecific) ++hidden_proto (__pthread_setspecific) + hidden_proto (_pthread_mutex_init) + #endif - Function: "log": - double: 1 diff --git a/srcpkgs/glibc/patches/glibc-upstream-03.patch b/srcpkgs/glibc/patches/glibc-upstream-03.patch index f6d9222b1c..066f304906 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-03.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-03.patch @@ -1,45 +1,299 @@ -From a4e5aa1a443cfad09bc98f9bb527995371a53a88 Mon Sep 17 00:00:00 2001 -From: Aurelien Jarno -Date: Thu, 3 Aug 2017 22:35:48 +0000 -Subject: [PATCH 03] Fix the return type of the getentropy stub +From 4b25485f03158959cff45379eecc1d73c7dcdd11 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Fri, 10 Aug 2018 11:19:26 +0200 +Subject: [PATCH 03] Linux: Rewrite __old_getdents64 [BZ #23497] -The return type of the getentropy stub is wrongly defined as ssize_t, -while both the header and the Linux implementation -define it as int. This patch fixes that. +Commit 298d0e3129c0b5137f4989275b13fe30d0733c4d ("Consolidate Linux +getdents{64} implementation") broke the implementation because it does +not take into account struct offset differences. -Changelog: - * stdlib/getentropy.c (getentropy): Change return type to int. -(cherry picked from commit 2b34e2716f1e84b2c3457ffc868c3dc775b55845) +The new implementation is close to the old one, before the +consolidation, but has been cleaned up slightly. + +(cherry picked from commit 690652882b499defb3d950dfeff8fe421d13cab5) --- - ChangeLog | 4 ++++ - stdlib/getentropy.c | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) + ChangeLog | 11 ++ + NEWS | 7 ++ + sysdeps/unix/sysv/linux/Makefile | 1 + + sysdeps/unix/sysv/linux/getdents64.c | 89 ++++++++++---- + .../unix/sysv/linux/tst-readdir64-compat.c | 111 ++++++++++++++++++ + 5 files changed, 194 insertions(+), 25 deletions(-) + create mode 100644 sysdeps/unix/sysv/linux/tst-readdir64-compat.c diff --git a/ChangeLog b/ChangeLog -index 3478699b10..4357ad1eb8 100644 +index dbcc56667b..f32ed3e74c 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,5 +1,9 @@ - 2017-08-03 Aurelien Jarno - -+ * stdlib/getentropy.c (getentropy): Change return type to int. +@@ -1,3 +1,14 @@ ++2018-08-10 Florian Weimer + -+2017-08-03 Aurelien Jarno ++ [BZ #23497] ++ * sysdeps/unix/sysv/linux/getdents64.c (handle_overflow): New ++ function. ++ (__old_getdents64): Use getdents64. Convert entries without ++ moving them. ++ * sysdeps/unix/sysv/linux/tst-readdir64-compat.c: New file. ++ * sysdeps/unix/sysv/linux/Makefile (tests-internal): Add ++ tst-readdir64-compat. + - * sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Regenerated. + 2018-08-08 Samuel Thibault - 2017-08-03 Florian Weimer -diff --git a/stdlib/getentropy.c b/stdlib/getentropy.c -index a71d4cd8f5..a88bbf8de3 100644 ---- a/stdlib/getentropy.c -+++ b/stdlib/getentropy.c -@@ -21,7 +21,7 @@ + * htl/Versions (__pthread_getspecific, __pthread_setspecific): Add +diff --git a/NEWS b/NEWS +index 154ab22d7c..b733755ff6 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,13 @@ See the end for copying conditions. + Please send GNU C library bug reports via + using `glibc' in the "product" field. + ++Version 2.28.1 ++ ++The following bugs are resolved with this release: ++ ++ [23497] readdir64@GLIBC_2.1 cannot parse the kernel directory stream ++ ++ + Version 2.28 - /* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on - success and -1 on failure. */ --ssize_t -+int - getentropy (void *buffer, size_t length) + Major new features: +diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile +index f71cc39c7e..773aaea0e9 100644 +--- a/sysdeps/unix/sysv/linux/Makefile ++++ b/sysdeps/unix/sysv/linux/Makefile +@@ -161,6 +161,7 @@ inhibit-glue = yes + + ifeq ($(subdir),dirent) + sysdep_routines += getdirentries getdirentries64 ++tests-internal += tst-readdir64-compat + endif + + ifeq ($(subdir),nis) +diff --git a/sysdeps/unix/sysv/linux/getdents64.c b/sysdeps/unix/sysv/linux/getdents64.c +index 3bde0cf4f0..bc140b5a7f 100644 +--- a/sysdeps/unix/sysv/linux/getdents64.c ++++ b/sysdeps/unix/sysv/linux/getdents64.c +@@ -33,41 +33,80 @@ strong_alias (__getdents64, __getdents) + # include + + # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) +-# include ++# include ++# include + +-/* kernel definition of as of 3.2. */ +-struct compat_linux_dirent ++static ssize_t ++handle_overflow (int fd, __off64_t offset, ssize_t count) { - __set_errno (ENOSYS); +- /* Both d_ino and d_off are compat_ulong_t which are defined in all +- architectures as 'u32'. */ +- uint32_t d_ino; +- uint32_t d_off; +- unsigned short d_reclen; +- char d_name[1]; +-}; ++ /* If this is the first entry in the buffer, we can report the ++ error. */ ++ if (count == 0) ++ { ++ __set_errno (EOVERFLOW); ++ return -1; ++ } ++ ++ /* Otherwise, seek to the overflowing entry, so that the next call ++ will report the error, and return the data read so far.. */ ++ if (__lseek64 (fd, offset, SEEK_SET) != 0) ++ return -1; ++ return count; ++} + + ssize_t + __old_getdents64 (int fd, char *buf, size_t nbytes) + { +- ssize_t retval = INLINE_SYSCALL_CALL (getdents, fd, buf, nbytes); ++ /* We do not move the individual directory entries. This is only ++ possible if the target type (struct __old_dirent64) is smaller ++ than the source type. */ ++ _Static_assert (offsetof (struct __old_dirent64, d_name) ++ <= offsetof (struct dirent64, d_name), ++ "__old_dirent64 is larger than dirent64"); ++ _Static_assert (__alignof__ (struct __old_dirent64) ++ <= __alignof__ (struct dirent64), ++ "alignment of __old_dirent64 is larger than dirent64"); + +- /* The kernel added the d_type value after the name. Change this now. */ +- if (retval != -1) ++ ssize_t retval = INLINE_SYSCALL_CALL (getdents64, fd, buf, nbytes); ++ if (retval > 0) + { +- union +- { +- struct compat_linux_dirent k; +- struct dirent u; +- } *kbuf = (void *) buf; +- +- while ((char *) kbuf < buf + retval) ++ char *p = buf; ++ char *end = buf + retval; ++ while (p < end) + { +- char d_type = *((char *) kbuf + kbuf->k.d_reclen - 1); +- memmove (kbuf->u.d_name, kbuf->k.d_name, +- strlen (kbuf->k.d_name) + 1); +- kbuf->u.d_type = d_type; ++ struct dirent64 *source = (struct dirent64 *) p; ++ ++ /* Copy out the fixed-size data. */ ++ __ino_t ino = source->d_ino; ++ __off64_t offset = source->d_off; ++ unsigned int reclen = source->d_reclen; ++ unsigned char type = source->d_type; ++ ++ /* Check for ino_t overflow. */ ++ if (__glibc_unlikely (ino != source->d_ino)) ++ return handle_overflow (fd, offset, p - buf); ++ ++ /* Convert to the target layout. Use a separate struct and ++ memcpy to side-step aliasing issues. */ ++ struct __old_dirent64 result; ++ result.d_ino = ino; ++ result.d_off = offset; ++ result.d_reclen = reclen; ++ result.d_type = type; ++ ++ /* Write the fixed-sized part of the result to the ++ buffer. */ ++ size_t result_name_offset = offsetof (struct __old_dirent64, d_name); ++ memcpy (p, &result, result_name_offset); ++ ++ /* Adjust the position of the name if necessary. Copy ++ everything until the end of the record, including the ++ terminating NUL byte. */ ++ if (result_name_offset != offsetof (struct dirent64, d_name)) ++ memmove (p + result_name_offset, source->d_name, ++ reclen - offsetof (struct dirent64, d_name)); + +- kbuf = (void *) ((char *) kbuf + kbuf->k.d_reclen); ++ p += reclen; + } + } + return retval; +diff --git a/sysdeps/unix/sysv/linux/tst-readdir64-compat.c b/sysdeps/unix/sysv/linux/tst-readdir64-compat.c +new file mode 100644 +index 0000000000..43c4a8477c +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/tst-readdir64-compat.c +@@ -0,0 +1,111 @@ ++/* Test readdir64 compatibility symbol. ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Copied from . */ ++struct __old_dirent64 ++ { ++ __ino_t d_ino; ++ __off64_t d_off; ++ unsigned short int d_reclen; ++ unsigned char d_type; ++ char d_name[256]; ++ }; ++ ++typedef struct __old_dirent64 *(*compat_readdir64_type) (DIR *); ++ ++#if TEST_COMPAT (libc, GLIBC_2_1, GLIBC_2_2) ++struct __old_dirent64 *compat_readdir64 (DIR *); ++compat_symbol_reference (libc, compat_readdir64, readdir64, GLIBC_2_1); ++#endif ++ ++static int ++do_test (void) ++{ ++#if TEST_COMPAT (libc, GLIBC_2_1, GLIBC_2_2) ++ ++ /* Directory stream using the non-compat readdir64 symbol. The test ++ checks against this. */ ++ DIR *dir_reference = opendir ("."); ++ TEST_VERIFY_EXIT (dir_reference != NULL); ++ DIR *dir_test = opendir ("."); ++ TEST_VERIFY_EXIT (dir_test != NULL); ++ ++ /* This loop assumes that the enumeration order is consistent for ++ two different handles. Nothing should write to the current ++ directory (in the source tree) while this test runs, so there ++ should not be any difference due to races. */ ++ size_t count = 0; ++ while (true) ++ { ++ errno = 0; ++ struct dirent64 *entry_reference = readdir64 (dir_reference); ++ if (entry_reference == NULL && errno != 0) ++ FAIL_EXIT1 ("readdir64 entry %zu: %m\n", count); ++ struct __old_dirent64 *entry_test = compat_readdir64 (dir_test); ++ if (entry_reference == NULL) ++ { ++ if (errno == EOVERFLOW) ++ { ++ TEST_VERIFY (entry_reference->d_ino ++ != (__ino_t) entry_reference->d_ino); ++ printf ("info: inode number overflow at entry %zu\n", count); ++ break; ++ } ++ if (errno != 0) ++ FAIL_EXIT1 ("compat readdir64 entry %zu: %m\n", count); ++ } ++ ++ /* Check that both streams end at the same time. */ ++ if (entry_reference == NULL) ++ { ++ TEST_VERIFY (entry_test == NULL); ++ break; ++ } ++ else ++ TEST_VERIFY_EXIT (entry_test != NULL); ++ ++ /* Check that the entries are the same. */ ++ TEST_COMPARE_BLOB (entry_reference->d_name, ++ strlen (entry_reference->d_name), ++ entry_test->d_name, strlen (entry_test->d_name)); ++ TEST_COMPARE (entry_reference->d_ino, entry_test->d_ino); ++ TEST_COMPARE (entry_reference->d_off, entry_test->d_off); ++ TEST_COMPARE (entry_reference->d_type, entry_test->d_type); ++ TEST_COMPARE (entry_reference->d_reclen, entry_test->d_reclen); ++ ++ ++count; ++ } ++ printf ("info: %zu directory entries found\n", count); ++ TEST_VERIFY (count >= 3); /* ".", "..", and some source files. */ ++ ++ TEST_COMPARE (closedir (dir_test), 0); ++ TEST_COMPARE (closedir (dir_reference), 0); ++#endif ++ return 0; ++} ++ ++#include diff --git a/srcpkgs/glibc/patches/glibc-upstream-04.patch b/srcpkgs/glibc/patches/glibc-upstream-04.patch index 9050cad1cc..bef7c4a875 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-04.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-04.patch @@ -1,92 +1,45 @@ -From 799859f6635d68487ea2472bd79d96a7639a1ab1 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Sun, 6 Aug 2017 10:44:30 -0700 -Subject: [PATCH 04] x86-64: Use _dl_runtime_resolve_opt only with AVX512F - [BZ #21871] +From d05b05d1570ba3ae354a2f5a3cfeefb373b09979 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Mon, 13 Aug 2018 14:28:07 +0200 +Subject: [PATCH 04] error, error_at_line: Add missing va_end calls -On AVX machines with XGETBV (ECX == 1) like Skylake processors, - -(gdb) disass _dl_runtime_resolve_avx_opt -Dump of assembler code for function _dl_runtime_resolve_avx_opt: - 0x0000000000015890 <+0>: push %rax - 0x0000000000015891 <+1>: push %rcx - 0x0000000000015892 <+2>: push %rdx - 0x0000000000015893 <+3>: mov $0x1,%ecx - 0x0000000000015898 <+8>: xgetbv - 0x000000000001589b <+11>: mov %eax,%r11d - 0x000000000001589e <+14>: pop %rdx - 0x000000000001589f <+15>: pop %rcx - 0x00000000000158a0 <+16>: pop %rax - 0x00000000000158a1 <+17>: and $0x4,%r11d - 0x00000000000158a5 <+21>: bnd je 0x16200 <_dl_runtime_resolve_sse_vex> -End of assembler dump. - -is slower than: - -(gdb) disass _dl_runtime_resolve_avx_slow -Dump of assembler code for function _dl_runtime_resolve_avx_slow: - 0x0000000000015850 <+0>: vorpd %ymm0,%ymm1,%ymm8 - 0x0000000000015854 <+4>: vorpd %ymm2,%ymm3,%ymm9 - 0x0000000000015858 <+8>: vorpd %ymm4,%ymm5,%ymm10 - 0x000000000001585c <+12>: vorpd %ymm6,%ymm7,%ymm11 - 0x0000000000015860 <+16>: vorpd %ymm8,%ymm9,%ymm9 - 0x0000000000015865 <+21>: vorpd %ymm10,%ymm11,%ymm10 - 0x000000000001586a <+26>: vpcmpeqd %xmm8,%xmm8,%xmm8 - 0x000000000001586f <+31>: vorpd %ymm9,%ymm10,%ymm10 - 0x0000000000015874 <+36>: vptest %ymm10,%ymm8 - 0x0000000000015879 <+41>: bnd jae 0x158b0 <_dl_runtime_resolve_avx> - 0x000000000001587c <+44>: vzeroupper - 0x000000000001587f <+47>: bnd jmpq 0x16200 <_dl_runtime_resolve_sse_vex> -End of assembler dump. -(gdb) - -since xgetbv takes much more cycles than single cycle operations like -vpord/vvpcmpeq/ptest. _dl_runtime_resolve_opt should be used only with -AVX512 where AVX512 instructions lead to lower CPU frequency on Skylake -server. - - [BZ #21871] - * sysdeps/x86/cpu-features.c (init_cpu_features): Set - bit_arch_Use_dl_runtime_resolve_opt only with AVX512F. - -(cherry picked from commit d2cf37c0a2a375cf2fde69f1afbcc49e45368fc4) +(cherry picked from commit b7b52b9dec337a08a89bc67638773be652eba332) --- - ChangeLog | 6 ++++++ - sysdeps/x86/cpu-features.c | 7 +++++-- - 2 files changed, 11 insertions(+), 2 deletions(-) + ChangeLog | 5 +++++ + misc/error.c | 2 ++ + 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog -index 4357ad1eb8..764c827161 100644 +index f32ed3e74c..cc918e96a3 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-06 H.J. Lu +@@ -1,3 +1,8 @@ ++2018-08-13 Florian Weimer + -+ [BZ #21871] -+ * sysdeps/x86/cpu-features.c (init_cpu_features): Set -+ bit_arch_Use_dl_runtime_resolve_opt only with AVX512F. ++ * misc/error.c (error): Add missing va_end call. ++ (error_at_line): Likewise. + - 2017-08-03 Aurelien Jarno + 2018-08-10 Florian Weimer - * stdlib/getentropy.c (getentropy): Change return type to int. -diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c -index 1d087ea732..6f900840d4 100644 ---- a/sysdeps/x86/cpu-features.c -+++ b/sysdeps/x86/cpu-features.c -@@ -244,10 +244,13 @@ init_cpu_features (struct cpu_features *cpu_features) - |= bit_arch_Prefer_No_AVX512; + [BZ #23497] +diff --git a/misc/error.c b/misc/error.c +index b4e8b6c938..03378e2f2a 100644 +--- a/misc/error.c ++++ b/misc/error.c +@@ -319,6 +319,7 @@ error (int status, int errnum, const char *message, ...) - /* To avoid SSE transition penalty, use _dl_runtime_resolve_slow. -- If XGETBV suports ECX == 1, use _dl_runtime_resolve_opt. */ -+ If XGETBV suports ECX == 1, use _dl_runtime_resolve_opt. -+ Use _dl_runtime_resolve_opt only with AVX512F since it is -+ slower than _dl_runtime_resolve_slow with AVX. */ - cpu_features->feature[index_arch_Use_dl_runtime_resolve_slow] - |= bit_arch_Use_dl_runtime_resolve_slow; -- if (cpu_features->max_cpuid >= 0xd) -+ if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) -+ && cpu_features->max_cpuid >= 0xd) - { - unsigned int eax; + va_start (args, message); + error_tail (status, errnum, message, args); ++ va_end (args); + #ifdef _LIBC + _IO_funlockfile (stderr); +@@ -390,6 +391,7 @@ error_at_line (int status, int errnum, const char *file_name, + + va_start (args, message); + error_tail (status, errnum, message, args); ++ va_end (args); + + #ifdef _LIBC + _IO_funlockfile (stderr); diff --git a/srcpkgs/glibc/patches/glibc-upstream-05.patch b/srcpkgs/glibc/patches/glibc-upstream-05.patch index ebc489d8ac..a2dd4d3dc4 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-05.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-05.patch @@ -1,209 +1,52 @@ -From 82efa1ffd43bed1494d20a4b86f6b15ac6bb5545 Mon Sep 17 00:00:00 2001 -From: Adhemerval Zanella -Date: Mon, 17 Jul 2017 10:59:59 -0300 -Subject: [PATCH 05] posix: Set p{read,write}v2 to return ENOTSUP (BZ#21780) +From bfcfa22589f2b4277a65e60c6b736b6bbfbd87d0 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 14 Aug 2018 10:51:07 +0200 +Subject: [PATCH 05] nscd: Deallocate existing user names in file parser -Different than other architectures hppa-linux-gnu define different values -for ENOTSUP and EOPNOTSUPP, where the later is a Linux specific one. -This leads to tst-preadwritev{64}v2 tests failures: +This avoids a theoretical memory leak (theoretical because it depends on +multiple server-user/stat-user directives in the configuration file). -$ ./testrun.sh misc/tst-preadvwritev2 -error: tst-preadvwritev2-common.c:35: preadv2 failure did not set errno to ENOTSUP (223) -error: 1 test failures - -The straightforward fix is to return the POSIX defined ENOTSUP on all -p{read,write}v{64}v2 implementations instead of Linux specific one. - -Checked on x86_64-linux-gnu and the tst-preadwritev{64}v2 on -hppa-linux-gnu (although due the installed kernel on my testing system -the pwritev{64}v2 with an invalid flag still fails due a known kernel -issue [1]). - - [BZ #21780] - * sysdeps/posix/preadv2.c (preadv2): Use ENOTSUP instead of - EOPNOTSUPP. - * sysdeps/posix/preadv64v2.c (preadv64v2): Likewise. - * sysdeps/posix/pwritev2.c (pwritev2): Likewise. - * sysdeps/posix/pwritev64v2.c (pwritev64v2): Likewise. - * sysdeps/unix/sysv/linux/preadv2.c (preadv2): Likewise. - * sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise. - * sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise. - * sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise. - -[1] https://sourceware.org/ml/libc-alpha/2017-06/msg00726.html - -Cherry-pick of 852d63120783fae5bf85a067320dc4ba1ed59f11 +(cherry picked from commit 2d7acfac3ebf266dcbc82d0d6cc576f626953a03) --- - ChangeLog | 13 +++++++++++++ - sysdeps/posix/preadv2.c | 2 +- - sysdeps/posix/preadv64v2.c | 2 +- - sysdeps/posix/pwritev2.c | 2 +- - sysdeps/posix/pwritev64v2.c | 2 +- - sysdeps/unix/sysv/linux/preadv2.c | 4 ++-- - sysdeps/unix/sysv/linux/preadv64v2.c | 4 ++-- - sysdeps/unix/sysv/linux/pwritev2.c | 4 ++-- - sysdeps/unix/sysv/linux/pwritev64v2.c | 4 ++-- - 9 files changed, 25 insertions(+), 12 deletions(-) + ChangeLog | 5 +++++ + nscd/nscd_conf.c | 6 +++++- + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog -index 764c827161..459062cc20 100644 +index cc918e96a3..0cbfb504f4 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,16 @@ -+2017-08-09 Adhemerval Zanella +@@ -1,3 +1,8 @@ ++2018-08-14 Florian Weimer + -+ [BZ #21780] -+ * sysdeps/posix/preadv2.c (preadv2): Use ENOTSUP instead of -+ EOPNOTSUPP. -+ * sysdeps/posix/preadv64v2.c (preadv64v2): Likewise. -+ * sysdeps/posix/pwritev2.c (pwritev2): Likewise. -+ * sysdeps/posix/pwritev64v2.c (pwritev64v2): Likewise. -+ * sysdeps/unix/sysv/linux/preadv2.c (preadv2): Likewise. -+ * sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise. -+ * sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise. -+ * sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise. ++ * nscd/nscd_conf.c (nscd_parse_file): Deallocate old storage for ++ server_user, stat_user. + - 2017-08-06 H.J. Lu + 2018-08-13 Florian Weimer - [BZ #21871] -diff --git a/sysdeps/posix/preadv2.c b/sysdeps/posix/preadv2.c -index 2a7cf11e27..d27f7028ed 100644 ---- a/sysdeps/posix/preadv2.c -+++ b/sysdeps/posix/preadv2.c -@@ -28,7 +28,7 @@ preadv2 (int fd, const struct iovec *vector, int count, OFF_T offset, - { - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } + * misc/error.c (error): Add missing va_end call. +diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c +index 265a02434d..7293b795b6 100644 +--- a/nscd/nscd_conf.c ++++ b/nscd/nscd_conf.c +@@ -190,7 +190,10 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb]) + if (!arg1) + error (0, 0, _("Must specify user name for server-user option")); + else +- server_user = xstrdup (arg1); ++ { ++ free ((char *) server_user); ++ server_user = xstrdup (arg1); ++ } + } + else if (strcmp (entry, "stat-user") == 0) + { +@@ -198,6 +201,7 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb]) + error (0, 0, _("Must specify user name for stat-user option")); + else + { ++ free ((char *) stat_user); + stat_user = xstrdup (arg1); -diff --git a/sysdeps/posix/preadv64v2.c b/sysdeps/posix/preadv64v2.c -index e084f3f9e1..ce7cb40bf2 100644 ---- a/sysdeps/posix/preadv64v2.c -+++ b/sysdeps/posix/preadv64v2.c -@@ -25,7 +25,7 @@ preadv64v2 (int fd, const struct iovec *vector, int count, OFF_T offset, - { - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - -diff --git a/sysdeps/posix/pwritev2.c b/sysdeps/posix/pwritev2.c -index 5b7650c4fc..7ec8cbc407 100644 ---- a/sysdeps/posix/pwritev2.c -+++ b/sysdeps/posix/pwritev2.c -@@ -28,7 +28,7 @@ pwritev2 (int fd, const struct iovec *vector, int count, OFF_T offset, - { - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - -diff --git a/sysdeps/posix/pwritev64v2.c b/sysdeps/posix/pwritev64v2.c -index 0f2f9ef863..be98aeed9d 100644 ---- a/sysdeps/posix/pwritev64v2.c -+++ b/sysdeps/posix/pwritev64v2.c -@@ -26,7 +26,7 @@ pwritev64v2 (int fd, const struct iovec *vector, int count, OFF_T offset, - { - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - -diff --git a/sysdeps/unix/sysv/linux/preadv2.c b/sysdeps/unix/sysv/linux/preadv2.c -index 11fe85eaa8..137e2dd791 100644 ---- a/sysdeps/unix/sysv/linux/preadv2.c -+++ b/sysdeps/unix/sysv/linux/preadv2.c -@@ -32,7 +32,7 @@ preadv2 (int fd, const struct iovec *vector, int count, off_t offset, - # ifdef __NR_preadv2 - ssize_t result = SYSCALL_CANCEL (preadv2, fd, vector, count, - LO_HI_LONG (offset), flags); -- if (result >= 0 || errno != ENOSYS) -+ if (result >= 0) - return result; - # endif - /* Trying to emulate the preadv2 syscall flags is troublesome: -@@ -46,7 +46,7 @@ preadv2 (int fd, const struct iovec *vector, int count, off_t offset, - - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - return preadv (fd, vector, count, offset); -diff --git a/sysdeps/unix/sysv/linux/preadv64v2.c b/sysdeps/unix/sysv/linux/preadv64v2.c -index 9d7f8c9893..8f413253f4 100644 ---- a/sysdeps/unix/sysv/linux/preadv64v2.c -+++ b/sysdeps/unix/sysv/linux/preadv64v2.c -@@ -30,7 +30,7 @@ preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset, - #ifdef __NR_preadv64v2 - ssize_t result = SYSCALL_CANCEL (preadv64v2, fd, vector, count, - LO_HI_LONG (offset), flags); -- if (result >= 0 || errno != ENOSYS) -+ if (result >= 0) - return result; - #endif - /* Trying to emulate the preadv2 syscall flags is troublesome: -@@ -44,7 +44,7 @@ preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset, - - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - return preadv64 (fd, vector, count, offset); -diff --git a/sysdeps/unix/sysv/linux/pwritev2.c b/sysdeps/unix/sysv/linux/pwritev2.c -index 72f0471f96..8e5032fe2f 100644 ---- a/sysdeps/unix/sysv/linux/pwritev2.c -+++ b/sysdeps/unix/sysv/linux/pwritev2.c -@@ -28,7 +28,7 @@ pwritev2 (int fd, const struct iovec *vector, int count, off_t offset, - # ifdef __NR_pwritev2 - ssize_t result = SYSCALL_CANCEL (pwritev2, fd, vector, count, - LO_HI_LONG (offset), flags); -- if (result >= 0 || errno != ENOSYS) -+ if (result >= 0) - return result; - # endif - /* Trying to emulate the pwritev2 syscall flags is troublesome: -@@ -42,7 +42,7 @@ pwritev2 (int fd, const struct iovec *vector, int count, off_t offset, - - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - return pwritev (fd, vector, count, offset); -diff --git a/sysdeps/unix/sysv/linux/pwritev64v2.c b/sysdeps/unix/sysv/linux/pwritev64v2.c -index def9a0bc57..d2800c6657 100644 ---- a/sysdeps/unix/sysv/linux/pwritev64v2.c -+++ b/sysdeps/unix/sysv/linux/pwritev64v2.c -@@ -30,7 +30,7 @@ pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset, - #ifdef __NR_pwritev64v2 - ssize_t result = SYSCALL_CANCEL (pwritev64v2, fd, vector, count, - LO_HI_LONG (offset), flags); -- if (result >= 0 || errno != ENOSYS) -+ if (result >= 0) - return result; - #endif - /* Trying to emulate the pwritev2 syscall flags is troublesome: -@@ -44,7 +44,7 @@ pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset, - - if (flags != 0) - { -- __set_errno (EOPNOTSUPP); -+ __set_errno (ENOTSUP); - return -1; - } - return pwritev64 (fd, vector, count, offset); + struct passwd *pw = getpwnam (stat_user); diff --git a/srcpkgs/glibc/patches/glibc-upstream-06.patch b/srcpkgs/glibc/patches/glibc-upstream-06.patch index d7a372b6f5..27567ef7aa 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-06.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-06.patch @@ -1,72 +1,348 @@ -From 302434688d925134065498b4a5574f6ee6bfb9fd Mon Sep 17 00:00:00 2001 +From 2f498f3d140ab5152bd784df2be7af7d9c5e63ed Mon Sep 17 00:00:00 2001 From: Florian Weimer -Date: Thu, 10 Aug 2017 09:10:36 +0200 -Subject: [PATCH 06] nss: Call __resolv_context_put before early return in - get*_r [BZ #21932] +Date: Tue, 14 Aug 2018 10:57:48 +0200 +Subject: [PATCH 06] nss_files: Fix file stream leak in aliases lookup [BZ + #23521] -This corrects an oversight introduced in commit -352f4ff9a268b81ef5d4b2413f582565806e4790 (resolv: Introduce struct -resolv_context). +In order to get a clean test case, it was necessary to fix partially +fixed bug 23522 as well. -(cherry picked from commit 3016149819268b14660f791b971910ccc2cc13e5) +(cherry picked from commit e95c6f61920a0f9237cfb292fa44ad500e1df09b) --- - ChangeLog | 6 ++++++ - NEWS | 1 + - nss/getXXbyYY_r.c | 10 +++++++++- - 3 files changed, 16 insertions(+), 1 deletion(-) + ChangeLog | 13 ++ + NEWS | 1 + + nss/Makefile | 3 + + nss/nss_files/files-alias.c | 9 ++ + nss/tst-nss-files-alias-leak.c | 237 +++++++++++++++++++++++++++++++++ + 5 files changed, 263 insertions(+) + create mode 100644 nss/tst-nss-files-alias-leak.c diff --git a/ChangeLog b/ChangeLog -index 459062cc20..3127648626 100644 +index 0cbfb504f4..d900e1eba1 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-09 Florian Weimer +@@ -1,3 +1,16 @@ ++2018-08-14 Florian Weimer + -+ [BZ #21932] -+ * nss/getXXbyYY_r.c (REENTRANT_NAME): Call __resolv_context_put -+ before early return. ++ [BZ #23521] ++ [BZ #23522] ++ * nss/nss_files/files-alias.c (get_next_alias): During :include: ++ processing, bail out if no room, and close the stream before ++ returning ERANGE. ++ * nss/Makefile (tests): Add tst-nss-files-alias-leak. ++ (tst-nss-files-alias-leak): Link with libdl. ++ (tst-nss-files-alias-leak.out): Depend on nss_files. + - 2017-08-09 Adhemerval Zanella ++ * nss/tst-nss-files-alias-leak.c: New file. ++ + 2018-08-14 Florian Weimer - [BZ #21780] + * nscd/nscd_conf.c (nscd_parse_file): Deallocate old storage for diff --git a/NEWS b/NEWS -index 9a64579658..ec6cf34122 100644 +index b733755ff6..873cf8f64f 100644 --- a/NEWS +++ b/NEWS -@@ -10,6 +10,7 @@ Version 2.26.1 +@@ -10,6 +10,7 @@ Version 2.28.1 The following bugs are resolved with this release: - [21885] getaddrinfo: Release resolver context on error in gethosts -+ [21932] Unpaired __resolv_context_get in generic get*_r implementation + [23497] readdir64@GLIBC_2.1 cannot parse the kernel directory stream ++ [23521] nss_files aliases database file stream leak + - Version 2.26 + Version 2.28 +diff --git a/nss/Makefile b/nss/Makefile +index 66fac7f5b8..5209fc0456 100644 +--- a/nss/Makefile ++++ b/nss/Makefile +@@ -65,6 +65,7 @@ ifeq (yes,$(build-shared)) + tests += tst-nss-files-hosts-erange + tests += tst-nss-files-hosts-multi + tests += tst-nss-files-hosts-getent ++tests += tst-nss-files-alias-leak + endif -diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c -index 6c547ea1ca..bce80e05dd 100644 ---- a/nss/getXXbyYY_r.c -+++ b/nss/getXXbyYY_r.c -@@ -234,6 +234,9 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, - H_ERRNO_VAR_P)) - { - case -1: -+# ifdef NEED__RES -+ __resolv_context_put (res_ctx); -+# endif - return errno; - case 1: - #ifdef NEED_H_ERRNO -@@ -253,7 +256,12 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, - nscd_status = NSCD_NAME (ADD_VARIABLES, resbuf, buffer, buflen, result - H_ERRNO_VAR); - if (nscd_status >= 0) -- return nscd_status; -+ { -+# ifdef NEED__RES -+ __resolv_context_put (res_ctx); -+# endif -+ return nscd_status; -+ } - } - #endif + # If we have a thread library then we can test cancellation against +@@ -171,3 +172,5 @@ endif + $(objpfx)tst-nss-files-hosts-erange: $(libdl) + $(objpfx)tst-nss-files-hosts-multi: $(libdl) + $(objpfx)tst-nss-files-hosts-getent: $(libdl) ++$(objpfx)tst-nss-files-alias-leak: $(libdl) ++$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so +diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c +index cfd34b66b9..35b0bfc5d2 100644 +--- a/nss/nss_files/files-alias.c ++++ b/nss/nss_files/files-alias.c +@@ -221,6 +221,13 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result, + { + while (! feof_unlocked (listfile)) + { ++ if (room_left < 2) ++ { ++ free (old_line); ++ fclose (listfile); ++ goto no_more_room; ++ } ++ + first_unused[room_left - 1] = '\xff'; + line = fgets_unlocked (first_unused, room_left, + listfile); +@@ -229,6 +236,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result, + if (first_unused[room_left - 1] != '\xff') + { + free (old_line); ++ fclose (listfile); + goto no_more_room; + } +@@ -256,6 +264,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result, + + __alignof__ (char *))) + { + free (old_line); ++ fclose (listfile); + goto no_more_room; + } + room_left -= ((first_unused - cp) +diff --git a/nss/tst-nss-files-alias-leak.c b/nss/tst-nss-files-alias-leak.c +new file mode 100644 +index 0000000000..26d38e2dba +--- /dev/null ++++ b/nss/tst-nss-files-alias-leak.c +@@ -0,0 +1,237 @@ ++/* Check for file descriptor leak in alias :include: processing (bug 23521). ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++static struct support_chroot *chroot_env; ++ ++/* Number of the aliases for the "many" user. This must be large ++ enough to trigger reallocation for the pointer array, but result in ++ answers below the maximum size tried in do_test. */ ++enum { many_aliases = 30 }; ++ ++static void ++prepare (int argc, char **argv) ++{ ++ chroot_env = support_chroot_create ++ ((struct support_chroot_configuration) { } ); ++ ++ char *path = xasprintf ("%s/etc/aliases", chroot_env->path_chroot); ++ add_temp_file (path); ++ support_write_file_string ++ (path, ++ "user1: :include:/etc/aliases.user1\n" ++ "user2: :include:/etc/aliases.user2\n" ++ "comment: comment1, :include:/etc/aliases.comment\n" ++ "many: :include:/etc/aliases.many\n"); ++ free (path); ++ ++ path = xasprintf ("%s/etc/aliases.user1", chroot_env->path_chroot); ++ add_temp_file (path); ++ support_write_file_string (path, "alias1\n"); ++ free (path); ++ ++ path = xasprintf ("%s/etc/aliases.user2", chroot_env->path_chroot); ++ add_temp_file (path); ++ support_write_file_string (path, "alias1a, alias2\n"); ++ free (path); ++ ++ path = xasprintf ("%s/etc/aliases.comment", chroot_env->path_chroot); ++ add_temp_file (path); ++ support_write_file_string ++ (path, ++ /* The line must be longer than the line with the :include: ++ directive in /etc/aliases. */ ++ "# Long line. ##############################################\n" ++ "comment2\n"); ++ free (path); ++ ++ path = xasprintf ("%s/etc/aliases.many", chroot_env->path_chroot); ++ add_temp_file (path); ++ FILE *fp = xfopen (path, "w"); ++ for (int i = 0; i < many_aliases; ++i) ++ fprintf (fp, "a%d\n", i); ++ TEST_VERIFY_EXIT (! ferror (fp)); ++ xfclose (fp); ++ free (path); ++} ++ ++/* The names of the users to test. */ ++static const char *users[] = { "user1", "user2", "comment", "many" }; ++ ++static void ++check_aliases (int id, const struct aliasent *e) ++{ ++ TEST_VERIFY_EXIT (id >= 0 || id < array_length (users)); ++ const char *name = users[id]; ++ TEST_COMPARE_BLOB (e->alias_name, strlen (e->alias_name), ++ name, strlen (name)); ++ ++ switch (id) ++ { ++ case 0: ++ TEST_COMPARE (e->alias_members_len, 1); ++ TEST_COMPARE_BLOB (e->alias_members[0], strlen (e->alias_members[0]), ++ "alias1", strlen ("alias1")); ++ break; ++ ++ case 1: ++ TEST_COMPARE (e->alias_members_len, 2); ++ TEST_COMPARE_BLOB (e->alias_members[0], strlen (e->alias_members[0]), ++ "alias1a", strlen ("alias1a")); ++ TEST_COMPARE_BLOB (e->alias_members[1], strlen (e->alias_members[1]), ++ "alias2", strlen ("alias2")); ++ break; ++ ++ case 2: ++ TEST_COMPARE (e->alias_members_len, 2); ++ TEST_COMPARE_BLOB (e->alias_members[0], strlen (e->alias_members[0]), ++ "comment1", strlen ("comment1")); ++ TEST_COMPARE_BLOB (e->alias_members[1], strlen (e->alias_members[1]), ++ "comment2", strlen ("comment2")); ++ break; ++ ++ case 3: ++ TEST_COMPARE (e->alias_members_len, many_aliases); ++ for (int i = 0; i < e->alias_members_len; ++i) ++ { ++ char alias[30]; ++ int len = snprintf (alias, sizeof (alias), "a%d", i); ++ TEST_VERIFY_EXIT (len > 0); ++ TEST_COMPARE_BLOB (e->alias_members[i], strlen (e->alias_members[i]), ++ alias, len); ++ } ++ break; ++ } ++} ++ ++static int ++do_test (void) ++{ ++ /* Make sure we don't try to load the module in the chroot. */ ++ if (dlopen (LIBNSS_FILES_SO, RTLD_NOW) == NULL) ++ FAIL_EXIT1 ("could not load " LIBNSS_FILES_SO ": %s", dlerror ()); ++ ++ /* Some of these descriptors will become unavailable if there is a ++ file descriptor leak. 10 is chosen somewhat arbitrarily. The ++ array must be longer than the number of files opened by nss_files ++ at the same time (currently that number is 2). */ ++ int next_descriptors[10]; ++ for (size_t i = 0; i < array_length (next_descriptors); ++i) ++ { ++ next_descriptors[i] = dup (0); ++ TEST_VERIFY_EXIT (next_descriptors[i] > 0); ++ } ++ for (size_t i = 0; i < array_length (next_descriptors); ++i) ++ xclose (next_descriptors[i]); ++ ++ support_become_root (); ++ if (!support_can_chroot ()) ++ return EXIT_UNSUPPORTED; ++ ++ __nss_configure_lookup ("aliases", "files"); ++ ++ xchroot (chroot_env->path_chroot); ++ ++ /* Attempt various buffer sizes. If the operation succeeds, we ++ expect correct data. */ ++ for (int id = 0; id < array_length (users); ++id) ++ { ++ bool found = false; ++ for (size_t size = 1; size <= 1000; ++size) ++ { ++ void *buffer = malloc (size); ++ struct aliasent result; ++ struct aliasent *res; ++ errno = EINVAL; ++ int ret = getaliasbyname_r (users[id], &result, buffer, size, &res); ++ if (ret == 0) ++ { ++ if (res != NULL) ++ { ++ found = true; ++ check_aliases (id, res); ++ } ++ else ++ { ++ support_record_failure (); ++ printf ("error: failed lookup for user \"%s\", size %zu\n", ++ users[id], size); ++ } ++ } ++ else if (ret != ERANGE) ++ { ++ support_record_failure (); ++ printf ("error: invalid return code %d (user \%s\", size %zu)\n", ++ ret, users[id], size); ++ } ++ free (buffer); ++ ++ /* Make sure that we did not have a file descriptor leak. */ ++ for (size_t i = 0; i < array_length (next_descriptors); ++i) ++ { ++ int new_fd = dup (0); ++ if (new_fd != next_descriptors[i]) ++ { ++ support_record_failure (); ++ printf ("error: descriptor %d at index %zu leaked" ++ " (user \"%s\", size %zu)\n", ++ next_descriptors[i], i, users[id], size); ++ ++ /* Close unexpected descriptor, the leak probing ++ descriptors, and the leaked descriptor ++ next_descriptors[i]. */ ++ xclose (new_fd); ++ for (size_t j = 0; j <= i; ++j) ++ xclose (next_descriptors[j]); ++ goto next_size; ++ } ++ } ++ for (size_t i = 0; i < array_length (next_descriptors); ++i) ++ xclose (next_descriptors[i]); ++ ++ next_size: ++ ; ++ } ++ if (!found) ++ { ++ support_record_failure (); ++ printf ("error: user %s not found\n", users[id]); ++ } ++ } ++ ++ support_chroot_free (chroot_env); ++ return 0; ++} ++ ++#define PREPARE prepare ++#include diff --git a/srcpkgs/glibc/patches/glibc-upstream-07.patch b/srcpkgs/glibc/patches/glibc-upstream-07.patch index 42eaaa6aad..f7c56ad282 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-07.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-07.patch @@ -1,71 +1,44 @@ -From c55ad6452e2d63ebf6fcaabb00bfd27aae02ffb6 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Thu, 10 Aug 2017 15:58:28 +0200 -Subject: [PATCH 07] malloc: Avoid optimizer warning with GCC 7 and -O3 +From b0aa03dfffc20ec7a00db73a3dedecb2130ca6ab Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Fri, 3 Aug 2018 13:43:31 -0400 +Subject: [PATCH 07] RISC-V: Fix rounding save/restore bug. -(cherry picked from commit eac43cbb8d808a40004aa0a4a286f5c5155beccb) +* sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv): +Fix rounding save-restore bug. + +Fixes about a hundred off-by-ULP failures in the math testsuite. + +(cherry picked from commit bf4181878780be9b53e37a3b0fbabc40cdd07649) --- - ChangeLog | 5 +++++ - malloc/malloc.c | 20 ++++++++++++++++---- - 2 files changed, 21 insertions(+), 4 deletions(-) + ChangeLog | 5 +++++ + sysdeps/riscv/rvf/math_private.h | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog -index 3127648626..5ea9b8baa7 100644 +index d900e1eba1..b1cba70bc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ -+2017-08-10 Florian Weimer ++2018-08-03 DJ Delorie + -+ * malloc/malloc.c (get_max_fast): Reimplement as an inline -+ function which calls __builtin_unreachable. ++ * sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv): ++ Fix rounding save-restore bug. + - 2017-08-09 Florian Weimer + 2018-08-14 Florian Weimer - [BZ #21932] -diff --git a/malloc/malloc.c b/malloc/malloc.c -index 54e406bcb6..e3ff778113 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -1658,6 +1658,9 @@ typedef struct malloc_chunk *mfastbinptr; - #define arena_is_corrupt(A) (((A)->flags & ARENA_CORRUPTION_BIT)) - #define set_arena_corrupt(A) ((A)->flags |= ARENA_CORRUPTION_BIT) - -+/* Maximum size of memory handled in fastbins. */ -+static INTERNAL_SIZE_T global_max_fast; -+ - /* - Set value of max_fast. - Use impossibly small value if 0. -@@ -1668,8 +1671,20 @@ typedef struct malloc_chunk *mfastbinptr; - #define set_max_fast(s) \ - global_max_fast = (((s) == 0) \ - ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)) --#define get_max_fast() global_max_fast - -+static inline INTERNAL_SIZE_T -+get_max_fast (void) -+{ -+ /* Tell the GCC optimizers that global_max_fast is never larger -+ than MAX_FAST_SIZE. This avoids out-of-bounds array accesses in -+ _int_malloc after constant propagation of the size parameter. -+ (The code never executes because malloc preserves the -+ global_max_fast invariant, but the optimizers may not recognize -+ this.) */ -+ if (global_max_fast > MAX_FAST_SIZE) -+ __builtin_unreachable (); -+ return global_max_fast; -+} - - /* - ----------- Internal state representation and initialization ----------- -@@ -1797,9 +1812,6 @@ static struct malloc_par mp_ = - #endif - }; - --/* Maximum size of memory handled in fastbins. */ --static INTERNAL_SIZE_T global_max_fast; -- - /* - Initialize a malloc_state struct. + [BZ #23521] +diff --git a/sysdeps/riscv/rvf/math_private.h b/sysdeps/riscv/rvf/math_private.h +index cdb7858fc8..ca587620cb 100644 +--- a/sysdeps/riscv/rvf/math_private.h ++++ b/sysdeps/riscv/rvf/math_private.h +@@ -72,8 +72,8 @@ libc_fesetround_riscv (int round) + static __always_inline void + libc_feholdexcept_setround_riscv (fenv_t *envp, int round) + { +- libc_fesetround_riscv (round); + libc_feholdexcept_riscv (envp); ++ libc_fesetround_riscv (round); + } + #define libc_feholdexcept_setround libc_feholdexcept_setround_riscv diff --git a/srcpkgs/glibc/patches/glibc-upstream-08.patch b/srcpkgs/glibc/patches/glibc-upstream-08.patch index 7384065ac2..f24b604f7a 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-08.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-08.patch @@ -1,76 +1,89 @@ -From 2aa1a7a8f8b9b7879bc6eb1c34d1580f992c406d Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Fri, 11 Aug 2017 15:48:14 +0200 -Subject: [PATCH 08] assert: Suppress pedantic warning caused by statement - expression [BZ #21242] +From 66fdfd57fe20616dc3333b0eb4f5a411e85fd8aa Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Fri, 3 Aug 2018 13:52:01 -0400 +Subject: [PATCH 08] Regen RISC-V rvd ULPs -(cherry picked from commit 8b2c63e4e2ad1fd161f80004ed30624f2a37b57b) +* sysdeps/riscv/rv64/rvd/libm-test-ulps: Update. + +Note: I regen'd these from scratch, but I'm only committing the +increases, as I only tested on hardware. There were a few 2->1 +decreases that I omitted, possibly "for now". + +(cherry picked from commit bb17621ab89b2135c4d8d0d250b2aab5aa3e36c4) --- - ChangeLog | 7 +++++++ - NEWS | 1 + - assert/assert.h | 12 +++++++++--- - 3 files changed, 17 insertions(+), 3 deletions(-) + ChangeLog | 2 ++ + sysdeps/riscv/rv64/rvd/libm-test-ulps | 16 ++++++++++++---- + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog -index 5ea9b8baa7..0057c0902a 100644 +index b1cba70bc4..e296da9699 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,10 @@ -+2017-08-11 Florian Weimer +@@ -3,6 +3,8 @@ + * sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv): + Fix rounding save-restore bug. + ++ * sysdeps/riscv/rv64/rvd/libm-test-ulps: Update. + -+ [BZ #21242] -+ * assert/assert.h [__GNUC__ && !__STRICT_ANSI__] (assert): -+ Suppress pedantic warning resulting from statement expression. -+ (__ASSERT_FUNCTION): Add missing __extension__. -+ - 2017-08-10 Florian Weimer + 2018-08-14 Florian Weimer - * malloc/malloc.c (get_max_fast): Reimplement as an inline -diff --git a/NEWS b/NEWS -index ec6cf34122..d57c4052cf 100644 ---- a/NEWS -+++ b/NEWS -@@ -9,6 +9,7 @@ Version 2.26.1 + [BZ #23521] +diff --git a/sysdeps/riscv/rv64/rvd/libm-test-ulps b/sysdeps/riscv/rv64/rvd/libm-test-ulps +index f8feadcd0d..61be2df60d 100644 +--- a/sysdeps/riscv/rv64/rvd/libm-test-ulps ++++ b/sysdeps/riscv/rv64/rvd/libm-test-ulps +@@ -1006,6 +1006,8 @@ ildouble: 2 + ldouble: 2 - The following bugs are resolved with this release: + Function: "cos": ++double: 1 ++idouble: 1 + ildouble: 1 + ldouble: 1 -+ [21242] assert: Suppress pedantic warning caused by statement expression - [21885] getaddrinfo: Release resolver context on error in gethosts - [21932] Unpaired __resolv_context_get in generic get*_r implementation - -diff --git a/assert/assert.h b/assert/assert.h -index 22f019537c..6801cfeb10 100644 ---- a/assert/assert.h -+++ b/assert/assert.h -@@ -91,13 +91,19 @@ __END_DECLS - ? __ASSERT_VOID_CAST (0) \ - : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION)) - # else -+/* The first occurrence of EXPR is not evaluated due to the sizeof, -+ but will trigger any pedantic warnings masked by the __extension__ -+ for the second occurrence. The explicit comparison against zero is -+ required to support function pointers and bit fields in this -+ context, and to suppress the evaluation of variable length -+ arrays. */ - # define assert(expr) \ -- ({ \ -+ ((void) sizeof ((expr) == 0), __extension__ ({ \ - if (expr) \ - ; /* empty */ \ - else \ - __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \ -- }) -+ })) - # endif +@@ -1348,9 +1350,9 @@ ildouble: 4 + ldouble: 4 + + Function: Imaginary part of "ctan_towardzero": +-double: 1 ++double: 2 + float: 2 +-idouble: 1 ++idouble: 2 + ifloat: 2 + ildouble: 5 + ldouble: 5 +@@ -1898,10 +1900,12 @@ ldouble: 2 + Function: "log_upward": + double: 1 + idouble: 1 +-ildouble: 1 +-ldouble: 1 ++ildouble: 2 ++ldouble: 2 + + Function: "pow": ++double: 1 ++idouble: 1 + ildouble: 2 + ldouble: 2 + +@@ -1930,6 +1934,8 @@ ildouble: 2 + ldouble: 2 + + Function: "sin": ++double: 1 ++idouble: 1 + ildouble: 1 + ldouble: 1 + +@@ -1952,6 +1958,8 @@ ildouble: 3 + ldouble: 3 + + Function: "sincos": ++double: 1 ++idouble: 1 + ildouble: 1 + ldouble: 1 - # ifdef __USE_GNU -@@ -113,7 +119,7 @@ __END_DECLS - C9x has a similar variable called __func__, but prefer the GCC one since - it demangles C++ function names. */ - # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4) --# define __ASSERT_FUNCTION __PRETTY_FUNCTION__ -+# define __ASSERT_FUNCTION __extension__ __PRETTY_FUNCTION__ - # else - # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L - # define __ASSERT_FUNCTION __func__ diff --git a/srcpkgs/glibc/patches/glibc-upstream-09.patch b/srcpkgs/glibc/patches/glibc-upstream-09.patch index a22b180f6c..1b4da4138b 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-09.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-09.patch @@ -1,80 +1,24 @@ -From 645b7635ba8fd58062245419e8bb668ab90cd3ec Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 7 Aug 2017 09:14:14 -0300 -Subject: [PATCH 09] powerpc: Restrict xssqrtqp operands to Vector Registers - (bug 21941) +From c87b5bab241c8d1e7709061c6b63f1b435ee3ac9 Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Wed, 22 Aug 2018 18:54:51 +0200 +Subject: [PATCH 09] Improve ChangeLog message. -POWER ISA 3.0 introduces the xssqrtqp instructions, which expects -operands to be in Vector Registers (Altivec/VMX), even though this -instruction belongs to the Vector-Scalar Instruction Set. - -In GCC's Extended Assembly for POWER, the 'wq' register constraint is -provided for use with IEEE 754 128-bit floating-point values. However, -this constraint does not limit the register allocation to Vector -Registers (Altivec/VMX) and could assign a Vector-Scalar Register (VSX) -to the operands of the instruction. - -This patch changes the register constraint used in sqrtf128 from 'wq' to -'v', in order to request a Vector Register (Altivec/VMX) for use with -the xssqrtqp instruction. - -Tested for powerpc64le and --with-cpu=power9. - - [BZ #21941] - * sysdeps/powerpc/fpu/math_private.h (__ieee754_sqrtf128): Since - xssqrtqp requires operands to be in Vector Registers - (Altivec/VMX), replace the register constraint 'wq' with 'v'. - * sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c - (__ieee754_sqrtf128): Likewise. - -(cherry picked from commit 4d98ace9de3183309cb394cd0110eda5ad2d2531) +(cherry picked from commit e5721f45f6377c27ccb2572001dc98f7a2e6a146) --- - ChangeLog | 9 +++++++++ - sysdeps/powerpc/fpu/math_private.h | 2 +- - sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c | 2 +- - 3 files changed, 11 insertions(+), 2 deletions(-) + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog -index 0057c0902a..6886cd9361 100644 +index e296da9699..b9e732a192 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,12 @@ -+2017-08-10 Gabriel F. T. Gomes -+ -+ [BZ #21941] -+ * sysdeps/powerpc/fpu/math_private.h (__ieee754_sqrtf128): Since -+ xssqrtqp requires operands to be in Vector Registers -+ (Altivec/VMX), replace the register constraint 'wq' with 'v'. -+ * sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c -+ (__ieee754_sqrtf128): Likewise. -+ - 2017-08-11 Florian Weimer +@@ -1,7 +1,7 @@ + 2018-08-03 DJ Delorie + + * sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv): +- Fix rounding save-restore bug. ++ Move libc_fesetround_riscv after libc_feholdexcept_riscv. + + * sysdeps/riscv/rv64/rvd/libm-test-ulps: Update. - [BZ #21242] -diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h -index d8fd4923ac..396fd0562e 100644 ---- a/sysdeps/powerpc/fpu/math_private.h -+++ b/sysdeps/powerpc/fpu/math_private.h -@@ -30,7 +30,7 @@ extern __always_inline _Float128 - __ieee754_sqrtf128 (_Float128 __x) - { - _Float128 __z; -- asm ("xssqrtqp %0,%1" : "=wq" (__z) : "wq" (__x)); -+ asm ("xssqrtqp %0,%1" : "=v" (__z) : "v" (__x)); - return __z; - } - #endif -diff --git a/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c b/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c -index 769d3f8922..59fd8269f5 100644 ---- a/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c -+++ b/sysdeps/powerpc/powerpc64le/power9/fpu/e_sqrtf128.c -@@ -30,7 +30,7 @@ __float128 - __ieee754_sqrtf128 (__float128 a) - { - __float128 z; -- asm ("xssqrtqp %0,%1" : "=wq" (z) : "wq" (a)); -+ asm ("xssqrtqp %0,%1" : "=v" (z) : "v" (a)); - return z; - } - strong_alias (__ieee754_sqrtf128, __sqrtf128_finite) diff --git a/srcpkgs/glibc/patches/glibc-upstream-10.patch b/srcpkgs/glibc/patches/glibc-upstream-10.patch index 1755cbd3ad..879c3df866 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-10.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-10.patch @@ -1,74 +1,61 @@ -From c2921b17a37e887b8a5ca9d84b875b9ba702b79c Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 21 Aug 2017 14:23:27 +0200 -Subject: [PATCH 10] Do not use __builtin_types_compatible_p in C++ mode - (bug 21930) +From aa8a3e4cdef20c50cb20f008864fff05cbfbdf29 Mon Sep 17 00:00:00 2001 +From: Martin Kuchta +Date: Mon, 27 Aug 2018 18:54:46 +0200 +Subject: [PATCH 10] pthread_cond_broadcast: Fix waiters-after-spinning case + [BZ #23538] -The logic to define isinf for float128 depends on the availability of -__builtin_types_compatible_p, which is only available in C mode, -however, the conditionals do not check for C or C++ mode. This lead to -an error in libstdc++ configure, as reported by bug 21930. - -This patch adds a conditional for C mode in the definition of isinf for -float128. No definition is provided in C++ mode, since libstdc++ -headers undefine isinf. - -Tested for powerpc64le (glibc test suite and libstdc++-v3 configure). - - [BZ #21930] - * math/math.h (isinf): Check if in C or C++ mode before using - __builtin_types_compatible_p, since this is a C mode feature. - -(cherry picked from commit 47a67213a9f51c5f8816d240500b10db605d8b77) +(cherry picked from commit 99ea93ca31795469d2a1f1570f17a5c39c2eb7e2) --- - ChangeLog | 6 ++++++ - NEWS | 1 + - math/math.h | 8 ++++++-- - 3 files changed, 13 insertions(+), 2 deletions(-) + ChangeLog | 8 ++++++++ + NEWS | 1 + + nptl/pthread_cond_common.c | 8 ++++++-- + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog -index 6886cd9361..415fa3cc79 100644 +index b9e732a192..ef83777833 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-18 Gabriel F. T. Gomes +@@ -1,3 +1,11 @@ ++2018-08-27 Martin Kuchta ++ Torvald Riegel + -+ [BZ #21930] -+ * math/math.h (isinf): Check if in C or C++ mode before using -+ __builtin_types_compatible_p, since this is a C mode feature. ++ [BZ #23538] ++ * nptl/pthread_cond_common.c (__condvar_quiesce_and_switch_g1): ++ Update r to include the set wake-request flag if waiters are ++ remaining after spinning. + - 2017-08-10 Gabriel F. T. Gomes + 2018-08-03 DJ Delorie - [BZ #21941] + * sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv): diff --git a/NEWS b/NEWS -index d57c4052cf..75b82c899e 100644 +index 873cf8f64f..3073712cba 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ The following bugs are resolved with this release: - [21242] assert: Suppress pedantic warning caused by statement expression - [21885] getaddrinfo: Release resolver context on error in gethosts -+ [21930] Do not use __builtin_types_compatible_p in C++ mode - [21932] Unpaired __resolv_context_get in generic get*_r implementation - - Version 2.26 -diff --git a/math/math.h b/math/math.h -index e21708045a..dea8dbe1ae 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -442,8 +442,12 @@ enum + [23497] readdir64@GLIBC_2.1 cannot parse the kernel directory stream + [23521] nss_files aliases database file stream leak ++ [23538] pthread_cond_broadcast: Fix waiters-after-spinning case - /* Return nonzero value if X is positive or negative infinity. */ - # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \ -- && !defined __SUPPORT_SNAN__ -- /* __builtin_isinf_sign is broken for float128 only before GCC 7.0. */ -+ && !defined __SUPPORT_SNAN__ && !defined __cplusplus -+ /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0, -+ use the helper function, __isinff128, with older compilers. This is -+ only provided for C mode, because in C++ mode, GCC has no support -+ for __builtin_types_compatible_p (and when in C++ mode, this macro is -+ not used anyway, because libstdc++ headers undefine it). */ - # define isinf(x) \ - (__builtin_types_compatible_p (__typeof (x), _Float128) \ - ? __isinff128 (x) : __builtin_isinf_sign (x)) + + Version 2.28 +diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c +index 8e425eb01e..479e54febb 100644 +--- a/nptl/pthread_cond_common.c ++++ b/nptl/pthread_cond_common.c +@@ -405,8 +405,12 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, + { + /* There is still a waiter after spinning. Set the wake-request + flag and block. Relaxed MO is fine because this is just about +- this futex word. */ +- r = atomic_fetch_or_relaxed (cond->__data.__g_refs + g1, 1); ++ this futex word. ++ ++ Update r to include the set wake-request flag so that the upcoming ++ futex_wait only blocks if the flag is still set (otherwise, we'd ++ violate the basic client-side futex protocol). */ ++ r = atomic_fetch_or_relaxed (cond->__data.__g_refs + g1, 1) | 1; + + if ((r >> 1) > 0) + futex_wait_simple (cond->__data.__g_refs + g1, r, private); diff --git a/srcpkgs/glibc/patches/glibc-upstream-11.patch b/srcpkgs/glibc/patches/glibc-upstream-11.patch index 32010111ee..b98b145d2b 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-11.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-11.patch @@ -1,68 +1,81 @@ -From 5e989c36934d0f0cf13b7a53ef2fa440bce39210 Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 14 Aug 2017 17:51:51 -0300 -Subject: [PATCH 11] Do not use generic selection in C++ mode +From 58559f14437d2aa71753a29fed435efa06aa4576 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Tue, 28 Aug 2018 21:54:28 +0200 +Subject: [PATCH 11] regex: fix uninitialized memory access -The logic to protect the use of generic selection (_Generic) does not -check for C or C++ mode, however, generic selection is a C-only -feature. +I introduced this bug into gnulib in commit +8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10; +eventually it was merged into glibc. The bug was found by +project-repo and reported here: +https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html +Diagnosis and draft fix reported by Assaf Gordon here: +https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html +https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html +* posix/regex_internal.c (build_wcs_upper_buffer): +Fix bug when mbrtowc returns 0. -Tested for powerpc64le. - - * misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if - in C++ mode. - -(cherry picked from commit 6913ad65e00bb32417ad39c41d292b976171e27e) +(cherry picked from commit bc680b336971305cb39896b30d72dc7101b62242) --- - ChangeLog | 5 +++++ - misc/sys/cdefs.h | 19 ++++++++++--------- - 2 files changed, 15 insertions(+), 9 deletions(-) + ChangeLog | 15 +++++++++++++++ + NEWS | 1 + + posix/regex_internal.c | 4 ++-- + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog -index 415fa3cc79..23c00aed09 100644 +index ef83777833..8625e6c9f5 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,5 +1,10 @@ - 2017-08-18 Gabriel F. T. Gomes - -+ * misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if -+ in C++ mode. +@@ -1,3 +1,18 @@ ++2018-08-25 Paul Eggert + -+2017-08-18 Gabriel F. T. Gomes ++ [BZ #23578] ++ regex: fix uninitialized memory access ++ I introduced this bug into gnulib in commit ++ 8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10; ++ eventually it was merged into glibc. The bug was found by ++ project-repo and reported here: ++ https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html ++ Diagnosis and draft fix reported by Assaf Gordon here: ++ https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html ++ https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html ++ * posix/regex_internal.c (build_wcs_upper_buffer): ++ Fix bug when mbrtowc returns 0. + - [BZ #21930] - * math/math.h (isinf): Check if in C or C++ mode before using - __builtin_types_compatible_p, since this is a C mode feature. -diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h -index 06523bfe9c..0c808216a4 100644 ---- a/misc/sys/cdefs.h -+++ b/misc/sys/cdefs.h -@@ -464,17 +464,18 @@ - # define __glibc_macro_warning(msg) - #endif + 2018-08-27 Martin Kuchta + Torvald Riegel --/* Support for generic selection (ISO C11) is available in GCC since -- version 4.9. Previous versions do not provide generic selection, -- even though they might set __STDC_VERSION__ to 201112L, when in -- -std=c11 mode. Thus, we must check for !defined __GNUC__ when -- testing __STDC_VERSION__ for generic selection support. -+/* Generic selection (ISO C11) is a C-only feature, available in GCC -+ since version 4.9. Previous versions do not provide generic -+ selection, even though they might set __STDC_VERSION__ to 201112L, -+ when in -std=c11 mode. Thus, we must check for !defined __GNUC__ -+ when testing __STDC_VERSION__ for generic selection support. - On the other hand, Clang also defines __GNUC__, so a clang-specific - check is required to enable the use of generic selection. */ --#if __GNUC_PREREQ (4, 9) \ -- || __glibc_clang_has_extension (c_generic_selections) \ -- || (!defined __GNUC__ && defined __STDC_VERSION__ \ -- && __STDC_VERSION__ >= 201112L) -+#if !defined __cplusplus \ -+ && (__GNUC_PREREQ (4, 9) \ -+ || __glibc_clang_has_extension (c_generic_selections) \ -+ || (!defined __GNUC__ && defined __STDC_VERSION__ \ -+ && __STDC_VERSION__ >= 201112L)) - # define __HAVE_GENERIC_SELECTION 1 - #else - # define __HAVE_GENERIC_SELECTION 0 +diff --git a/NEWS b/NEWS +index 3073712cba..2855ffde58 100644 +--- a/NEWS ++++ b/NEWS +@@ -12,6 +12,7 @@ The following bugs are resolved with this release: + [23497] readdir64@GLIBC_2.1 cannot parse the kernel directory stream + [23521] nss_files aliases database file stream leak + [23538] pthread_cond_broadcast: Fix waiters-after-spinning case ++ [23578] regex: Fix memory overread in re_compile_pattern + + + Version 2.28 +diff --git a/posix/regex_internal.c b/posix/regex_internal.c +index 7f0083b918..b10588f1cc 100644 +--- a/posix/regex_internal.c ++++ b/posix/regex_internal.c +@@ -317,7 +317,7 @@ build_wcs_upper_buffer (re_string_t *pstr) + mbclen = __mbrtowc (&wc, + ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx + + byte_idx), remain_len, &pstr->cur_state); +- if (BE (mbclen < (size_t) -2, 1)) ++ if (BE (0 < mbclen && mbclen < (size_t) -2, 1)) + { + wchar_t wcu = __towupper (wc); + if (wcu != wc) +@@ -386,7 +386,7 @@ build_wcs_upper_buffer (re_string_t *pstr) + else + p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; + mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); +- if (BE (mbclen < (size_t) -2, 1)) ++ if (BE (0 < mbclen && mbclen < (size_t) -2, 1)) + { + wchar_t wcu = __towupper (wc); + if (wcu != wc) diff --git a/srcpkgs/glibc/patches/glibc-upstream-12.patch b/srcpkgs/glibc/patches/glibc-upstream-12.patch index 3405c118b4..a94a8258e2 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-12.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-12.patch @@ -1,116 +1,60 @@ -From fb9a781e9d62c5d7a1f4196915cdfb7c6db59a0c Mon Sep 17 00:00:00 2001 +From 0b79004569e5ce1669136b8c41564c3809730f15 Mon Sep 17 00:00:00 2001 From: Florian Weimer -Date: Mon, 21 Aug 2017 16:13:49 +0200 -Subject: [PATCH 12] assert: Support types without operator== (int) [BZ - #21972] +Date: Tue, 28 Aug 2018 12:57:46 +0200 +Subject: [PATCH 12] regex: Add test tst-regcomp-truncated [BZ #23578] -(cherry picked from commit b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c) +(cherry picked from commit 761404b74d9853ce1608195e24f25b78a910591a) --- - ChangeLog | 11 +++++++ - NEWS | 1 + - assert/Makefile | 11 ++++++- - assert/assert.h | 16 ++++++---- - assert/tst-assert-c++.cc | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ - assert/tst-assert-g++.cc | 19 ++++++++++++ - 6 files changed, 129 insertions(+), 7 deletions(-) - create mode 100644 assert/tst-assert-c++.cc - create mode 100644 assert/tst-assert-g++.cc + ChangeLog | 7 ++ + posix/Makefile | 3 +- + posix/tst-regcomp-truncated.c | 191 ++++++++++++++++++++++++++++++++++ + 3 files changed, 200 insertions(+), 1 deletion(-) + create mode 100644 posix/tst-regcomp-truncated.c diff --git a/ChangeLog b/ChangeLog -index 23c00aed09..8bc3ad9a46 100644 +index 8625e6c9f5..94b8718365 100644 --- a/ChangeLog +++ b/ChangeLog -@@ -1,3 +1,14 @@ -+2017-08-21 Florian Weimer +@@ -1,3 +1,10 @@ ++2018-08-28 Florian Weimer + -+ [BZ #21972] -+ * assert/assert.h (assert): Use static_cast (bool) for C++. -+ Use the ternary operator in the warning branch for GNU C. -+ * assert/Makefile (tests): Add tst-assert-c++, tst-assert-g++. -+ (CFLAGS-tst-assert-c++.o): Compile in C++11 mode. -+ (CFLAGS-tst-assert-g++.o): Compile in GnU C++11 mode. -+ (LDLIBS-tst-assert-c++, LDLIBS-tst-assert-g++): Link with libstdc++. -+ * assert/tst-assert-c++.cc, assert/tst-assert-g++.cc: New files. ++ [BZ #23578] ++ * posix/tst-regcomp-truncated.c: New file. ++ * posix/Makefile (tests): Add it. ++ (tst-regcomp-truncated.out): Depend on generated locales. + - 2017-08-18 Gabriel F. T. Gomes + 2018-08-25 Paul Eggert - * misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if -diff --git a/NEWS b/NEWS -index 75b82c899e..1996e5fbef 100644 ---- a/NEWS -+++ b/NEWS -@@ -13,6 +13,7 @@ The following bugs are resolved with this release: - [21885] getaddrinfo: Release resolver context on error in gethosts - [21930] Do not use __builtin_types_compatible_p in C++ mode - [21932] Unpaired __resolv_context_get in generic get*_r implementation -+ [21972] assert macro requires operator== (int) for its argument type - - Version 2.26 + [BZ #23578] +diff --git a/posix/Makefile b/posix/Makefile +index 00c62841a2..83162123f9 100644 +--- a/posix/Makefile ++++ b/posix/Makefile +@@ -96,7 +96,7 @@ tests := test-errno tstgetopt testfnm runtests runptests \ + tst-posix_fadvise tst-posix_fadvise64 \ + tst-sysconf-empty-chroot tst-glob_symlinks tst-fexecve \ + tst-glob-tilde test-ssize-max tst-spawn4 bug-regex37 \ +- bug-regex38 ++ bug-regex38 tst-regcomp-truncated + tests-internal := bug-regex5 bug-regex20 bug-regex33 \ + tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \ + tst-glob_lstat_compat tst-spawn4-compat +@@ -194,6 +194,7 @@ $(objpfx)tst-regex2.out: $(gen-locales) + $(objpfx)tst-regexloc.out: $(gen-locales) + $(objpfx)tst-rxspencer.out: $(gen-locales) + $(objpfx)tst-rxspencer-no-utf8.out: $(gen-locales) ++$(objpfx)tst-regcomp-truncated.out: $(gen-locales) + endif -diff --git a/assert/Makefile b/assert/Makefile -index 1c3be9b01f..9ec1be81a9 100644 ---- a/assert/Makefile -+++ b/assert/Makefile -@@ -25,6 +25,15 @@ include ../Makeconfig - headers := assert.h - - routines := assert assert-perr __assert --tests := test-assert test-assert-perr -+tests := test-assert test-assert-perr tst-assert-c++ tst-assert-g++ - - include ../Rules -+ -+ifeq ($(have-cxx-thread_local),yes) -+CFLAGS-tst-assert-c++.o = -std=c++11 -+LDLIBS-tst-assert-c++ = -lstdc++ -+CFLAGS-tst-assert-g++.o = -std=gnu++11 -+LDLIBS-tst-assert-g++ = -lstdc++ -+else -+tests-unsupported += tst-assert-c++ tst-assert-g++ -+endif -diff --git a/assert/assert.h b/assert/assert.h -index 6801cfeb10..640c95c063 100644 ---- a/assert/assert.h -+++ b/assert/assert.h -@@ -85,7 +85,12 @@ __END_DECLS - /* When possible, define assert so that it does not add extra - parentheses around EXPR. Otherwise, those added parentheses would - suppress warnings we'd expect to be detected by gcc's -Wparentheses. */ --# if !defined __GNUC__ || defined __STRICT_ANSI__ -+# if defined __cplusplus -+# define assert(expr) \ -+ (static_cast (expr) \ -+ ? void (0) \ -+ : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION)) -+# elif !defined __GNUC__ || defined __STRICT_ANSI__ - # define assert(expr) \ - ((expr) \ - ? __ASSERT_VOID_CAST (0) \ -@@ -93,12 +98,11 @@ __END_DECLS - # else - /* The first occurrence of EXPR is not evaluated due to the sizeof, - but will trigger any pedantic warnings masked by the __extension__ -- for the second occurrence. The explicit comparison against zero is -- required to support function pointers and bit fields in this -- context, and to suppress the evaluation of variable length -- arrays. */ -+ for the second occurrence. The ternary operator is required to -+ support function pointers and bit fields in this context, and to -+ suppress the evaluation of variable length arrays. */ - # define assert(expr) \ -- ((void) sizeof ((expr) == 0), __extension__ ({ \ -+ ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \ - if (expr) \ - ; /* empty */ \ - else \ -diff --git a/assert/tst-assert-c++.cc b/assert/tst-assert-c++.cc + # If we will use the generic uname implementation, we must figure out what +diff --git a/posix/tst-regcomp-truncated.c b/posix/tst-regcomp-truncated.c new file mode 100644 -index 0000000000..12a5e690cb +index 0000000000..a4a1581bbc --- /dev/null -+++ b/assert/tst-assert-c++.cc -@@ -0,0 +1,78 @@ -+/* Tests for interactions between C++ and assert. -+ Copyright (C) 2017 Free Software Foundation, Inc. ++++ b/posix/tst-regcomp-truncated.c +@@ -0,0 +1,191 @@ ++/* Test compilation of truncated regular expressions. ++ Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or @@ -127,89 +71,177 @@ index 0000000000..12a5e690cb + License along with the GNU C Library; if not, see + . */ + -+#include ++/* This test constructs various patterns in an attempt to trigger ++ over-reading the regular expression compiler, such as bug ++ 23578. */ + -+/* The C++ standard requires that if the assert argument is a constant -+ subexpression, then the assert itself is one, too. */ -+constexpr int -+check_constexpr () -+{ -+ return (assert (true), 1); -+} ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + -+/* Objects of this class can be contextually converted to bool, but -+ cannot be compared to int. */ -+struct no_int -+{ -+ no_int () = default; -+ no_int (const no_int &) = delete; -+ -+ explicit operator bool () const ++/* Locales to test. */ ++static const char locales[][17] = + { -+ return true; -+ } ++ "C", ++ "en_US.UTF-8", ++ "de_DE.ISO-8859-1", ++ }; + -+ bool operator! () const; /* No definition. */ -+ template bool operator== (T) const; /* No definition. */ -+ template bool operator!= (T) const; /* No definition. */ -+}; -+ -+/* This class tests that operator== is not used by assert. */ -+struct bool_and_int -+{ -+ bool_and_int () = default; -+ bool_and_int (const no_int &) = delete; -+ -+ explicit operator bool () const ++/* Syntax options. Will be combined with other flags. */ ++static const reg_syntax_t syntaxes[] = + { -+ return true; -+ } ++ RE_SYNTAX_EMACS, ++ RE_SYNTAX_AWK, ++ RE_SYNTAX_GNU_AWK, ++ RE_SYNTAX_POSIX_AWK, ++ RE_SYNTAX_GREP, ++ RE_SYNTAX_EGREP, ++ RE_SYNTAX_POSIX_EGREP, ++ RE_SYNTAX_POSIX_BASIC, ++ RE_SYNTAX_POSIX_EXTENDED, ++ RE_SYNTAX_POSIX_MINIMAL_EXTENDED, ++ }; + -+ bool operator! () const; /* No definition. */ -+ template bool operator== (T) const; /* No definition. */ -+ template bool operator!= (T) const; /* No definition. */ -+}; ++/* Trailing characters placed after the initial character. */ ++static const char trailing_strings[][4] = ++ { ++ "", ++ "[", ++ "\\", ++ "[\\", ++ "(", ++ "(\\", ++ "\\(", ++ }; + +static int -+do_test () ++do_test (void) +{ -+ { -+ no_int value; -+ assert (value); -+ } ++ /* Staging buffer for the constructed regular expression. */ ++ char buffer[16]; + -+ { -+ bool_and_int value; -+ assert (value); -+ } ++ /* Allocation used to detect over-reading by the regular expression ++ compiler. */ ++ struct support_next_to_fault ntf ++ = support_next_to_fault_allocate (sizeof (buffer)); ++ ++ /* Arbitrary Unicode codepoint at which we stop generating ++ characters. We do not probe the whole range because that would ++ take too long due to combinatorical exploision as the result of ++ combination with other flags. */ ++ static const wchar_t last_character = 0xfff; ++ ++ for (size_t locale_idx = 0; locale_idx < array_length (locales); ++ ++ locale_idx) ++ { ++ if (setlocale (LC_ALL, locales[locale_idx]) == NULL) ++ { ++ support_record_failure (); ++ printf ("error: setlocale (\"%s\"): %m", locales[locale_idx]); ++ continue; ++ } ++ if (test_verbose > 0) ++ printf ("info: testing locale \"%s\"\n", locales[locale_idx]); ++ ++ for (wchar_t wc = 0; wc <= last_character; ++wc) ++ { ++ char *after_wc; ++ if (wc == 0) ++ { ++ /* wcrtomb treats L'\0' in a special way. */ ++ *buffer = '\0'; ++ after_wc = &buffer[1]; ++ } ++ else ++ { ++ mbstate_t ps = { }; ++ size_t ret = wcrtomb (buffer, wc, &ps); ++ if (ret == (size_t) -1) ++ { ++ /* EILSEQ means that the target character set ++ cannot encode the character. */ ++ if (errno != EILSEQ) ++ { ++ support_record_failure (); ++ printf ("error: wcrtomb (0x%x) failed: %m\n", ++ (unsigned) wc); ++ } ++ continue; ++ } ++ TEST_VERIFY_EXIT (ret != 0); ++ after_wc = &buffer[ret]; ++ } ++ ++ for (size_t trailing_idx = 0; ++ trailing_idx < array_length (trailing_strings); ++ ++trailing_idx) ++ { ++ char *after_trailing ++ = stpcpy (after_wc, trailing_strings[trailing_idx]); ++ ++ for (int do_nul = 0; do_nul < 2; ++do_nul) ++ { ++ char *after_nul; ++ if (do_nul) ++ { ++ *after_trailing = '\0'; ++ after_nul = &after_trailing[1]; ++ } ++ else ++ after_nul = after_trailing; ++ ++ size_t length = after_nul - buffer; ++ ++ /* Make sure that the faulting region starts ++ after the used portion of the buffer. */ ++ char *ntf_start = ntf.buffer + sizeof (buffer) - length; ++ memcpy (ntf_start, buffer, length); ++ ++ for (const reg_syntax_t *psyntax = syntaxes; ++ psyntax < array_end (syntaxes); ++psyntax) ++ for (int do_icase = 0; do_icase < 2; ++do_icase) ++ { ++ re_syntax_options = *psyntax; ++ if (do_icase) ++ re_syntax_options |= RE_ICASE; ++ ++ regex_t reg; ++ memset (®, 0, sizeof (reg)); ++ const char *msg = re_compile_pattern ++ (ntf_start, length, ®); ++ if (msg != NULL) ++ { ++ if (test_verbose > 0) ++ { ++ char *quoted = support_quote_blob ++ (buffer, length); ++ printf ("info: compilation failed for pattern" ++ " \"%s\", syntax 0x%lx: %s\n", ++ quoted, re_syntax_options, msg); ++ free (quoted); ++ } ++ } ++ else ++ regfree (®); ++ } ++ } ++ } ++ } ++ } ++ ++ support_next_to_fault_free (&ntf); + + return 0; +} + +#include -diff --git a/assert/tst-assert-g++.cc b/assert/tst-assert-g++.cc -new file mode 100644 -index 0000000000..8c06402825 ---- /dev/null -+++ b/assert/tst-assert-g++.cc -@@ -0,0 +1,19 @@ -+/* Tests for interactions between C++ and assert. GNU C++11 version. -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#include diff --git a/srcpkgs/glibc/patches/glibc-upstream-13.patch b/srcpkgs/glibc/patches/glibc-upstream-13.patch index dc98e5c88b..19ddc16436 100644 --- a/srcpkgs/glibc/patches/glibc-upstream-13.patch +++ b/srcpkgs/glibc/patches/glibc-upstream-13.patch @@ -1,27 +1,52 @@ -From 3aeab55ee17ca527e4597bc8397c0434c3f8b34e Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 21 Aug 2017 15:45:57 -0300 -Subject: [PATCH 13] Add missing bug fixes to NEWS +From 1fe2b9ca8a50aaa789d72944b5a91f1d35337adc Mon Sep 17 00:00:00 2001 +From: Stefan Liebler +Date: Thu, 6 Sep 2018 14:27:03 +0200 +Subject: [PATCH 13] Fix segfault in maybe_script_execute. +If glibc is built with gcc 8 and -march=z900, +the testcase posix/tst-spawn4-compat crashes with a segfault. + +In function maybe_script_execute, the new_argv array is dynamically +initialized on stack with (argc + 1) elements. +The function wants to add _PATH_BSHELL as the first argument +and writes out of bounds of new_argv. +There is an off-by-one because maybe_script_execute fails to count +the terminating NULL when sizing new_argv. + +ChangeLog: + + * sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute): + Increment size of new_argv by one. + +(cherry picked from commit 28669f86f6780a18daca264f32d66b1428c9c6f1) --- - NEWS | 3 +++ - 1 file changed, 3 insertions(+) + ChangeLog | 5 +++++ + sysdeps/unix/sysv/linux/spawni.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) -diff --git a/NEWS b/NEWS -index 1996e5fbef..0534c5296e 100644 ---- a/NEWS -+++ b/NEWS -@@ -10,9 +10,12 @@ Version 2.26.1 - The following bugs are resolved with this release: +diff --git a/ChangeLog b/ChangeLog +index 94b8718365..d9e7e6f1d8 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,8 @@ ++2018-09-06 Stefan Liebler ++ ++ * sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute): ++ Increment size of new_argv by one. ++ + 2018-08-28 Florian Weimer - [21242] assert: Suppress pedantic warning caused by statement expression -+ [21780] posix: Set p{read,write}v2 to return ENOTSUP -+ [21871] x86-64: Use _dl_runtime_resolve_opt only with AVX512F - [21885] getaddrinfo: Release resolver context on error in gethosts - [21930] Do not use __builtin_types_compatible_p in C++ mode - [21932] Unpaired __resolv_context_get in generic get*_r implementation -+ [21941] powerpc: Restrict xssqrtqp operands to Vector Registers - [21972] assert macro requires operator== (int) for its argument type - - Version 2.26 - + [BZ #23578] +diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c +index cf0213ece5..85239cedbf 100644 +--- a/sysdeps/unix/sysv/linux/spawni.c ++++ b/sysdeps/unix/sysv/linux/spawni.c +@@ -101,7 +101,7 @@ maybe_script_execute (struct posix_spawn_args *args) + ptrdiff_t argc = args->argc; + + /* Construct an argument list for the shell. */ +- char *new_argv[argc + 1]; ++ char *new_argv[argc + 2]; + new_argv[0] = (char *) _PATH_BSHELL; + new_argv[1] = (char *) args->file; + if (argc > 1) diff --git a/srcpkgs/glibc/patches/glibc-upstream-14.patch b/srcpkgs/glibc/patches/glibc-upstream-14.patch deleted file mode 100644 index f5052b97d8..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-14.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 77db8772bd3f6f2bbad697dcf46861ce310f5b95 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Thu, 10 Aug 2017 16:06:52 +0200 -Subject: [PATCH 14] __inet6_scopeid_pton: Remove attribute_hidden, - internal_function - -The hidden attribute was overridden by libc_hidden_proto on GNU/Linux. -It is incorrect because the function is used from nscd. - -internal_function is not supposed to be used across DSO boundaries, -so this commit removes it (again, due to the use in nscd). - -(cherry picked from commit f87cc2bfba9b844da48a63441c6099342b1551c7) ---- - ChangeLog | 7 +++++++ - inet/inet6_scopeid_pton.c | 2 +- - inet/net-internal.h | 3 +-- - 3 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 8bc3ad9a46..ad05da8ade 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,10 @@ -+2017-08-10 Florian Weimer -+ -+ * inet/net-internal.h (__inet6_scopeid_pton): Remove -+ attribute_hidden, internal_function. -+ * inet/inet6_scopeid_pton.c (__inet6_scopeid_pton): Remove -+ internal_function. -+ - 2017-08-21 Florian Weimer - - [BZ #21972] -diff --git a/inet/inet6_scopeid_pton.c b/inet/inet6_scopeid_pton.c -index e09b1cb34d..cc8803fa10 100644 ---- a/inet/inet6_scopeid_pton.c -+++ b/inet/inet6_scopeid_pton.c -@@ -28,7 +28,7 @@ - - /* Parse SOURCE as a scope ID for ADDRESS. Return 0 on success and -1 - on error. */ --internal_function int -+int - __inet6_scopeid_pton (const struct in6_addr *address, const char *scope, - uint32_t *result) - { -diff --git a/inet/net-internal.h b/inet/net-internal.h -index 2b2632c7ba..b2135893e8 100644 ---- a/inet/net-internal.h -+++ b/inet/net-internal.h -@@ -25,8 +25,7 @@ - #include - - int __inet6_scopeid_pton (const struct in6_addr *address, -- const char *scope, uint32_t *result) -- internal_function attribute_hidden; -+ const char *scope, uint32_t *result); - libc_hidden_proto (__inet6_scopeid_pton) - - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-15.patch b/srcpkgs/glibc/patches/glibc-upstream-15.patch deleted file mode 100644 index 30580f4c77..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-15.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 6043d77a47de297b62084c1c261cdada082bf09c Mon Sep 17 00:00:00 2001 -From: Andreas Schwab -Date: Mon, 28 Aug 2017 19:49:18 +0200 -Subject: [PATCH 15] ldd: never run file directly - -(cherry picked from commit eedca9772e99c72ab4c3c34e43cc764250aa3e3c) ---- - ChangeLog | 6 ++++++ - NEWS | 9 +++++++++ - elf/ldd.bash.in | 14 +------------- - 3 files changed, 16 insertions(+), 13 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index ad05da8ade..fa27c6f66f 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-16 Andreas Schwab -+ -+ [BZ #16750] -+ CVE-2009-5064 -+ * elf/ldd.bash.in: Never run file directly. -+ - 2017-08-10 Florian Weimer - - * inet/net-internal.h (__inet6_scopeid_pton): Remove -diff --git a/NEWS b/NEWS -index 0534c5296e..756e849643 100644 ---- a/NEWS -+++ b/NEWS -@@ -7,8 +7,17 @@ using `glibc' in the "product" field. - - Version 2.26.1 - -+Security related changes: -+ -+ CVE-2009-5064: The ldd script would sometimes run the program under -+ examination directly, without preventing code execution through the -+ dynamic linker. (The glibc project disputes that this is a security -+ vulnerability; only trusted binaries must be examined using the ldd -+ script.) -+ - The following bugs are resolved with this release: - -+ [16750] ldd: Never run file directly. - [21242] assert: Suppress pedantic warning caused by statement expression - [21780] posix: Set p{read,write}v2 to return ENOTSUP - [21871] x86-64: Use _dl_runtime_resolve_opt only with AVX512F -diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in -index 7dd1fccf24..686785e235 100644 ---- a/elf/ldd.bash.in -+++ b/elf/ldd.bash.in -@@ -164,18 +164,6 @@ warning: you do not have execution permission for" "\`$file'" >&2 - fi - done - case $ret in -- 0) -- # If the program exits with exit code 5, it means the process has been -- # invoked with __libc_enable_secure. Fall back to running it through -- # the dynamic linker. -- try_trace "$file" -- rc=$? -- if [ $rc = 5 ]; then -- try_trace "$RTLD" "$file" -- rc=$? -- fi -- [ $rc = 0 ] || result=1 -- ;; - 1) - # This can be a non-ELF binary or no binary at all. - nonelf "$file" || { -@@ -183,7 +171,7 @@ warning: you do not have execution permission for" "\`$file'" >&2 - result=1 - } - ;; -- 2) -+ 0|2) - try_trace "$RTLD" "$file" || result=1 - ;; - *) - diff --git a/srcpkgs/glibc/patches/glibc-upstream-16.patch b/srcpkgs/glibc/patches/glibc-upstream-16.patch deleted file mode 100644 index df031adc53..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-16.patch +++ /dev/null @@ -1,244 +0,0 @@ -From ef8566d72af5e03c1b82cf02efb794268a347f8c Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 14 Aug 2017 13:46:15 -0300 -Subject: [PATCH 16] Provide a C++ version of issignaling that does not use - __MATH_TG - -The macro __MATH_TG contains the logic to select between long double and -_Float128, when these types are ABI-distinct. This logic relies on -__builtin_types_compatible_p, which is not available in C++ mode. - -On the other hand, C++ function overloading provides the means to -distinguish between the floating-point types. The overloading -resolution will match the correct parameter regardless of type -qualifiers, i.e.: const and volatile. - -Tested for powerpc64le, s390x, and x86_64. - - * math/math.h [defined __cplusplus] (issignaling): Provide a C++ - definition for issignaling that does not rely on __MATH_TG, - since __MATH_TG uses __builtin_types_compatible_p, which is only - available in C mode. - (CFLAGS-test-math-issignaling.cc): New variable. - * math/Makefile [CXX] (tests): Add test-math-issignaling. - * math/test-math-issignaling.cc: New test for C++ implementation - of type-generic issignaling. - * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] - (CXXFLAGS-test-math-issignaling.cc): Add -mfloat128 to the build - options of test-math-issignaling on powerpc64le. - -(cherry picked from commit a16e8bc08edca84d507715c66d6cddbbc7ed3b62) ---- - ChangeLog | 14 +++++ - math/Makefile | 3 +- - math/math.h | 19 +++++- - math/test-math-issignaling.cc | 113 +++++++++++++++++++++++++++++++++++ - sysdeps/powerpc/powerpc64le/Makefile | 1 + - 5 files changed, 148 insertions(+), 2 deletions(-) - create mode 100644 math/test-math-issignaling.cc - -diff --git a/ChangeLog b/ChangeLog -index fa27c6f66f..527026ba5d 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,17 @@ -+2017-08-22 Gabriel F. T. Gomes -+ -+ * math/math.h [defined __cplusplus] (issignaling): Provide a C++ -+ definition for issignaling that does not rely on __MATH_TG, -+ since __MATH_TG uses __builtin_types_compatible_p, which is only -+ available in C mode. -+ (CFLAGS-test-math-issignaling.cc): New variable. -+ * math/Makefile [CXX] (tests): Add test-math-issignaling. -+ * math/test-math-issignaling.cc: New test for C++ implementation -+ of type-generic issignaling. -+ * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] -+ (CXXFLAGS-test-math-issignaling.cc): Add -mfloat128 to the build -+ options of test-math-issignaling on powerpc64le. -+ - 2017-08-16 Andreas Schwab - - [BZ #16750] -diff --git a/math/Makefile b/math/Makefile -index e09b0c0545..0130fcf38b 100644 ---- a/math/Makefile -+++ b/math/Makefile -@@ -203,7 +203,7 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \ - test-signgam-ullong-static test-signgam-ullong-init-static - - ifneq (,$(CXX)) --tests += test-math-isinff test-math-iszero -+tests += test-math-isinff test-math-iszero test-math-issignaling - endif - - ifneq (no,$(PERL)) -@@ -350,6 +350,7 @@ CFLAGS-test-signgam-ullong-init-static.c = -std=c99 - - CFLAGS-test-math-isinff.cc = -std=gnu++11 - CFLAGS-test-math-iszero.cc = -std=gnu++11 -+CFLAGS-test-math-issignaling.cc = -std=gnu++11 - - CFLAGS-test-iszero-excess-precision.c = -fexcess-precision=standard - CFLAGS-test-iseqsig-excess-precision.c = -fexcess-precision=standard -diff --git a/math/math.h b/math/math.h -index dea8dbe1ae..add86af724 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -474,7 +474,24 @@ enum - # include - - /* Return nonzero value if X is a signaling NaN. */ --# define issignaling(x) __MATH_TG ((x), __issignaling, (x)) -+# ifndef __cplusplus -+# define issignaling(x) __MATH_TG ((x), __issignaling, (x)) -+# else -+ /* In C++ mode, __MATH_TG cannot be used, because it relies on -+ __builtin_types_compatible_p, which is a C-only builtin. On the -+ other hand, overloading provides the means to distinguish between -+ the floating-point types. The overloading resolution will match -+ the correct parameter (regardless of type qualifiers (i.e.: const -+ and volatile). */ -+extern "C++" { -+inline int issignaling (float __val) { return __issignalingf (__val); } -+inline int issignaling (double __val) { return __issignaling (__val); } -+inline int issignaling (long double __val) { return __issignalingl (__val); } -+# if __HAVE_DISTINCT_FLOAT128 -+inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } -+# endif -+} /* extern C++ */ -+# endif - - /* Return nonzero value if X is subnormal. */ - # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) -diff --git a/math/test-math-issignaling.cc b/math/test-math-issignaling.cc -new file mode 100644 -index 0000000000..22ae9e1bca ---- /dev/null -+++ b/math/test-math-issignaling.cc -@@ -0,0 +1,113 @@ -+/* Test for the C++ implementation of issignaling. -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#define _GNU_SOURCE 1 -+#include -+#include -+ -+#include -+ -+/* There is no signaling_NaN for _Float128 in std::numeric_limits. -+ Include ieee754_float128.h and use the bitfields in the union -+ ieee854_float128.ieee_nan to build a signaling NaN. */ -+#if __HAVE_DISTINCT_FLOAT128 -+# include -+#endif -+ -+static bool errors; -+ -+static void -+check (int actual, int expected, const char *actual_expr, int line) -+{ -+ if (actual != expected) -+ { -+ errors = true; -+ printf ("%s:%d: error: %s\n", __FILE__, line, actual_expr); -+ printf ("%s:%d: expected: %d\n", __FILE__, line, expected); -+ printf ("%s:%d: actual: %d\n", __FILE__, line, actual); -+ } -+} -+ -+#define CHECK(actual, expected) \ -+ check ((actual), (expected), #actual, __LINE__) -+ -+template -+static void -+check_type () -+{ -+ typedef std::numeric_limits limits; -+ CHECK (issignaling (T{0}), 0); -+ if (limits::has_infinity) -+ { -+ CHECK (issignaling (limits::infinity ()), 0); -+ CHECK (issignaling (-limits::infinity ()), 0); -+ } -+ if (limits::has_quiet_NaN) -+ CHECK (issignaling (limits::quiet_NaN ()), 0); -+ if (limits::has_signaling_NaN) -+ CHECK (issignaling (limits::signaling_NaN ()), 1); -+} -+ -+#if __HAVE_DISTINCT_FLOAT128 -+static void -+check_float128 () -+{ -+ ieee854_float128 q; -+ -+ q.d = 0; -+ CHECK (issignaling (q.d), 0); -+ -+ /* Infinity. */ -+ q.ieee.negative = 0; -+ q.ieee.exponent = 0x7FFF; -+ q.ieee.mantissa0 = 0x0000; -+ q.ieee.mantissa1 = 0x00000000; -+ q.ieee.mantissa2 = 0x00000000; -+ q.ieee.mantissa3 = 0x00000000; -+ CHECK (issignaling (q.d), 0); -+ -+ /* Quiet NaN. */ -+ q.ieee_nan.quiet_nan = 1; -+ q.ieee_nan.mantissa0 = 0x0000; -+ CHECK (issignaling (q.d), 0); -+ -+ /* Still a quiet NaN. */ -+ q.ieee_nan.quiet_nan = 1; -+ q.ieee_nan.mantissa0 = 0x4000; -+ CHECK (issignaling (q.d), 0); -+ -+ /* Signaling NaN. */ -+ q.ieee_nan.quiet_nan = 0; -+ q.ieee_nan.mantissa0 = 0x4000; -+ CHECK (issignaling (q.d), 1); -+} -+#endif -+ -+static int -+do_test (void) -+{ -+ check_type (); -+ check_type (); -+ check_type (); -+#if __HAVE_DISTINCT_FLOAT128 -+ check_float128 (); -+#endif -+ return errors; -+} -+ -+#include -diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile -index 77617b670a..19adbfa1c1 100644 ---- a/sysdeps/powerpc/powerpc64le/Makefile -+++ b/sysdeps/powerpc/powerpc64le/Makefile -@@ -16,6 +16,7 @@ $(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128 - $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128 - $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128 - CFLAGS-libm-test-support-float128.c += -mfloat128 -+CFLAGS-test-math-issignaling.cc += -mfloat128 - $(objpfx)test-float128% $(objpfx)test-ifloat128%: \ - gnulib-tests += $(f128-loader-link) - endif - diff --git a/srcpkgs/glibc/patches/glibc-upstream-17.patch b/srcpkgs/glibc/patches/glibc-upstream-17.patch deleted file mode 100644 index db039425ad..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-17.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 35dded99a89db873b06270ca7f21245a0faf712a Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Wed, 23 Aug 2017 10:16:54 -0300 -Subject: [PATCH 17] Fix the C++ version of issignaling when - __NO_LONG_DOUBLE_MATH is defined - -When __NO_LONG_DOUBLE_MATH is defined, __issignalingl is not available, -thus issignaling with long double argument should call __issignaling, -instead. - -Tested for powerpc64le. - - * math/math.h [defined __cplusplus] (issignaling): In the long - double case, call __issignalingl only if __NO_LONG_DOUBLE_MATH - is not defined. Call __issignaling, otherwise. - -(cherry picked from commit 3d7b66f66cb223e899a7ebc0f4c20f13e711c9e0) ---- - ChangeLog | 6 ++++++ - math/math.h | 10 +++++++++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 527026ba5d..04b56b555c 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-24 Gabriel F. T. Gomes -+ -+ * math/math.h [defined __cplusplus] (issignaling): In the long -+ double case, call __issignalingl only if __NO_LONG_DOUBLE_MATH -+ is not defined. Call __issignaling, otherwise. -+ - 2017-08-22 Gabriel F. T. Gomes - - * math/math.h [defined __cplusplus] (issignaling): Provide a C++ -diff --git a/math/math.h b/math/math.h -index add86af724..60dfa31592 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -486,7 +486,15 @@ enum - extern "C++" { - inline int issignaling (float __val) { return __issignalingf (__val); } - inline int issignaling (double __val) { return __issignaling (__val); } --inline int issignaling (long double __val) { return __issignalingl (__val); } -+inline int -+issignaling (long double __val) -+{ -+# ifdef __NO_LONG_DOUBLE_MATH -+ return __issignaling (__val); -+# else -+ return __issignalingl (__val); -+# endif -+} - # if __HAVE_DISTINCT_FLOAT128 - inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } - # endif - diff --git a/srcpkgs/glibc/patches/glibc-upstream-18.patch b/srcpkgs/glibc/patches/glibc-upstream-18.patch deleted file mode 100644 index 6808c0f512..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-18.patch +++ /dev/null @@ -1,232 +0,0 @@ -From 58270c0049404ef2f878fdd45df55f17f0b8c1f7 Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Tue, 22 Aug 2017 16:34:42 -0300 -Subject: [PATCH 18] Provide a C++ version of iszero that does not use - __MATH_TG (bug 21930) - -When signaling nans are enabled (with -fsignaling-nans), the C++ version -of iszero uses the fpclassify macro, which is defined with __MATH_TG. -However, when support for float128 is available, __MATH_TG uses the -builtin __builtin_types_compatible_p, which is only available in C mode. - -This patch refactors the C++ version of iszero so that it uses function -overloading to select between the floating-point types, instead of -relying on fpclassify and __MATH_TG. - -Tested for powerpc64le, s390x, x86_64, and with build-many-glibcs.py. - - [BZ #21930] - * math/math.h [defined __cplusplus && defined __SUPPORT_SNAN__] - (iszero): New C++ implementation that does not use - fpclassify/__MATH_TG/__builtin_types_compatible_p, when - signaling nans are enabled, since __builtin_types_compatible_p - is a C-only feature. - * math/test-math-iszero.cc: When __HAVE_DISTINCT_FLOAT128 is - defined, include ieee754_float128.h for access to the union and - member ieee854_float128.ieee. - [__HAVE_DISTINCT_FLOAT128] (do_test): Call check_float128. - [__HAVE_DISTINCT_FLOAT128] (check_float128): New function. - * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] - (CXXFLAGS-test-math-iszero.cc): Add -mfloat128 to the build - options of test-math-zero on powerpc64le. - -(cherry picked from commit 42496114ec0eb7d6d039d05d4262e109951c600c) ---- - ChangeLog | 17 ++++++++ - math/math.h | 33 +++++++++++++-- - math/test-math-iszero.cc | 79 ++++++++++++++++++++++++++++++++++++ - sysdeps/powerpc/powerpc64le/Makefile | 3 +- - 4 files changed, 127 insertions(+), 5 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 04b56b555c..23ded7f03d 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,20 @@ -+2017-08-28 Gabriel F. T. Gomes -+ -+ [BZ #21930] -+ * math/math.h [defined __cplusplus && defined __SUPPORT_SNAN__] -+ (iszero): New C++ implementation that does not use -+ fpclassify/__MATH_TG/__builtin_types_compatible_p, when -+ signaling nans are enabled, since __builtin_types_compatible_p -+ is a C-only feature. -+ * math/test-math-iszero.cc: When __HAVE_DISTINCT_FLOAT128 is -+ defined, include ieee754_float128.h for access to the union and -+ member ieee854_float128.ieee. -+ [__HAVE_DISTINCT_FLOAT128] (do_test): Call check_float128. -+ [__HAVE_DISTINCT_FLOAT128] (check_float128): New function. -+ * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] -+ (CXXFLAGS-test-math-iszero.cc): Add -mfloat128 to the build -+ options of test-math-zero on powerpc64le. -+ - 2017-08-24 Gabriel F. T. Gomes - - * math/math.h [defined __cplusplus] (issignaling): In the long -diff --git a/math/math.h b/math/math.h -index 60dfa31592..7c0fc6dbb3 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -513,15 +513,40 @@ inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } - # endif - # else /* __cplusplus */ - extern "C++" { -+# ifdef __SUPPORT_SNAN__ -+inline int -+iszero (float __val) -+{ -+ return __fpclassifyf (__val) == FP_ZERO; -+} -+inline int -+iszero (double __val) -+{ -+ return __fpclassify (__val) == FP_ZERO; -+} -+inline int -+iszero (long double __val) -+{ -+# ifdef __NO_LONG_DOUBLE_MATH -+ return __fpclassify (__val) == FP_ZERO; -+# else -+ return __fpclassifyl (__val) == FP_ZERO; -+# endif -+} -+# if __HAVE_DISTINCT_FLOAT128 -+inline int -+iszero (_Float128 __val) -+{ -+ return __fpclassifyf128 (__val) == FP_ZERO; -+} -+# endif -+# else - template inline bool - iszero (__T __val) - { --# ifdef __SUPPORT_SNAN__ -- return fpclassify (__val) == FP_ZERO; --# else - return __val == 0; --# endif - } -+# endif - } /* extern C++ */ - # endif /* __cplusplus */ - #endif /* Use IEC_60559_BFP_EXT. */ -diff --git a/math/test-math-iszero.cc b/math/test-math-iszero.cc -index 027e972654..5c07261626 100644 ---- a/math/test-math-iszero.cc -+++ b/math/test-math-iszero.cc -@@ -22,6 +22,13 @@ - - #include - -+/* Support for _Float128 in std::numeric_limits is limited. -+ Include ieee754_float128.h and use the bitfields in the union -+ ieee854_float128.ieee_nan to build corner-case inputs. */ -+#if __HAVE_DISTINCT_FLOAT128 -+# include -+#endif -+ - static bool errors; - - static void -@@ -72,12 +79,84 @@ check_type () - std::numeric_limits::has_denorm == std::denorm_absent); - } - -+#if __HAVE_DISTINCT_FLOAT128 -+static void -+check_float128 () -+{ -+ ieee854_float128 q; -+ -+ q.d = 0.0Q; -+ CHECK (iszero (q.d), 1); -+ q.d = -0.0Q; -+ CHECK (iszero (q.d), 1); -+ q.d = 1.0Q; -+ CHECK (iszero (q.d), 0); -+ q.d = -1.0Q; -+ CHECK (iszero (q.d), 0); -+ -+ /* Normal min. */ -+ q.ieee.negative = 0; -+ q.ieee.exponent = 0x0001; -+ q.ieee.mantissa0 = 0x0000; -+ q.ieee.mantissa1 = 0x00000000; -+ q.ieee.mantissa2 = 0x00000000; -+ q.ieee.mantissa3 = 0x00000000; -+ CHECK (iszero (q.d), 0); -+ q.ieee.negative = 1; -+ CHECK (iszero (q.d), 0); -+ -+ /* Normal max. */ -+ q.ieee.negative = 0; -+ q.ieee.exponent = 0x7FFE; -+ q.ieee.mantissa0 = 0xFFFF; -+ q.ieee.mantissa1 = 0xFFFFFFFF; -+ q.ieee.mantissa2 = 0xFFFFFFFF; -+ q.ieee.mantissa3 = 0xFFFFFFFF; -+ CHECK (iszero (q.d), 0); -+ q.ieee.negative = 1; -+ CHECK (iszero (q.d), 0); -+ -+ /* Infinity. */ -+ q.ieee.negative = 0; -+ q.ieee.exponent = 0x7FFF; -+ q.ieee.mantissa0 = 0x0000; -+ q.ieee.mantissa1 = 0x00000000; -+ q.ieee.mantissa2 = 0x00000000; -+ q.ieee.mantissa3 = 0x00000000; -+ CHECK (iszero (q.d), 0); -+ -+ /* Quiet NaN. */ -+ q.ieee_nan.quiet_nan = 1; -+ q.ieee_nan.mantissa0 = 0x0000; -+ CHECK (iszero (q.d), 0); -+ -+ /* Signaling NaN. */ -+ q.ieee_nan.quiet_nan = 0; -+ q.ieee_nan.mantissa0 = 0x4000; -+ CHECK (iszero (q.d), 0); -+ -+ /* Denormal min. */ -+ q.ieee.negative = 0; -+ q.ieee.exponent = 0x0000; -+ q.ieee.mantissa0 = 0x0000; -+ q.ieee.mantissa1 = 0x00000000; -+ q.ieee.mantissa2 = 0x00000000; -+ q.ieee.mantissa3 = 0x00000001; -+ CHECK (iszero (q.d), 0); -+ q.ieee.negative = 1; -+ CHECK (iszero (q.d), 0); -+} -+#endif -+ - static int - do_test (void) - { - check_type (); - check_type (); - check_type (); -+#if __HAVE_DISTINCT_FLOAT128 -+ check_float128 (); -+#endif - return errors; - } - -diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile -index 19adbfa1c1..dea2290736 100644 ---- a/sysdeps/powerpc/powerpc64le/Makefile -+++ b/sysdeps/powerpc/powerpc64le/Makefile -@@ -17,7 +17,8 @@ $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += - - $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128 - CFLAGS-libm-test-support-float128.c += -mfloat128 - CFLAGS-test-math-issignaling.cc += -mfloat128 --$(objpfx)test-float128% $(objpfx)test-ifloat128%: \ -+CFLAGS-test-math-iszero.cc += -mfloat128 -+$(objpfx)test-float128% $(objpfx)test-ifloat128% $(objpfx)test-math-iszero: \ - gnulib-tests += $(f128-loader-link) - endif - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-19.patch b/srcpkgs/glibc/patches/glibc-upstream-19.patch deleted file mode 100644 index 9689b977f2..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-19.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 947e2e0a9410c18eb44144456c7fe8e7c0e2a999 Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Tue, 22 Aug 2017 00:30:51 +0000 -Subject: [PATCH 19] Fix position of tests-unsupported definition in - assert/Makefile. - -tests-unsupported has to be defined before the inclusion of Rules in a -subdirectory Makefile; otherwise it is ineffective. This patch fixes -the ordering in assert/Makefile, where a recent test addition put -tests-unsupported too late (resulting in build failures when the C++ -compiler was missing or broken, and thereby showing up the unrelated -bug 21987). - -Incidentally, I don't see why these tests depend on -$(have-cxx-thread_local) rather than just a working C++ compiler. - -Tested in such a configuration (broken compiler/libstdc++) with -build-many-glibcs.py. - - * assert/Makefile [$(have-cxx-thread_local)]: Move conditional - variable definitions above inclusion of ../Rules. - -(cherry picked from commit 75dfe623df945db7dd3c12a206d743c45c16b5ed) ---- - ChangeLog | 5 +++++ - assert/Makefile | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 23ded7f03d..87fa54c57b 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,8 @@ -+2017-08-22 Joseph Myers -+ -+ * assert/Makefile [$(have-cxx-thread_local)]: Move conditional -+ variable definitions above inclusion of ../Rules. -+ - 2017-08-28 Gabriel F. T. Gomes - - [BZ #21930] -diff --git a/assert/Makefile b/assert/Makefile -index 9ec1be81a9..222ab516f0 100644 ---- a/assert/Makefile -+++ b/assert/Makefile -@@ -27,8 +27,6 @@ headers := assert.h - routines := assert assert-perr __assert - tests := test-assert test-assert-perr tst-assert-c++ tst-assert-g++ - --include ../Rules -- - ifeq ($(have-cxx-thread_local),yes) - CFLAGS-tst-assert-c++.o = -std=c++11 - LDLIBS-tst-assert-c++ = -lstdc++ -@@ -37,3 +35,5 @@ LDLIBS-tst-assert-g++ = -lstdc++ - else - tests-unsupported += tst-assert-c++ tst-assert-g++ - endif -+ -+include ../Rules - diff --git a/srcpkgs/glibc/patches/glibc-upstream-20.patch b/srcpkgs/glibc/patches/glibc-upstream-20.patch deleted file mode 100644 index b55d344877..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-20.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 4fdd75e4463801b9d8f329769df1a26145560656 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Tue, 8 Aug 2017 18:48:05 +0200 -Subject: [PATCH 20] getaddrinfo: Remove unreachable return statement from - gaih_inet - -(cherry picked from commit 0df595b23a829c9169ec418a19eef9006b4ae801) ---- - ChangeLog | 5 +++++ - sysdeps/posix/getaddrinfo.c | 10 +++------- - 2 files changed, 8 insertions(+), 7 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 87fa54c57b..591c753fcc 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,8 @@ -+2017-08-08 Florian Weimer -+ -+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Remove unreachable -+ return statement. -+ - 2017-08-22 Joseph Myers - - * assert/Makefile [$(have-cxx-thread_local)]: Move conditional -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 699411cc92..09f85fc472 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -420,13 +420,9 @@ gaih_inet (const char *name, const struct gaih_service *service, - alloca_account (sizeof (struct gaih_servtuple), - alloca_used); - -- if ((rc = gaih_inet_serv (service->name, -- tp, req, newp, tmpbuf))) -- { -- if (rc) -- continue; -- return rc; -- } -+ if (gaih_inet_serv (service->name, -+ tp, req, newp, tmpbuf) != 0) -+ continue; - - *pst = newp; - pst = &(newp->next); - diff --git a/srcpkgs/glibc/patches/glibc-upstream-21.patch b/srcpkgs/glibc/patches/glibc-upstream-21.patch deleted file mode 100644 index 54baffe363..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-21.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 5253749232749adb535d9b2bf7d43173b191ebef Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Mon, 4 Sep 2017 11:44:10 +0200 -Subject: [PATCH 21] Synchronize support/ infrastructure with master - -This commit updates the support/ subdirectory to -commit 65329bd233db9d1b8b94e90734a564705b619260 -on the master branch. ---- - support/namespace.h | 11 ++++++++--- - support/support_chroot.c | 32 +++++++++++++++++++++++--------- - 2 files changed, 31 insertions(+), 12 deletions(-) - -diff --git a/support/namespace.h b/support/namespace.h -index 859c2fda3f..9eddb1a0e9 100644 ---- a/support/namespace.h -+++ b/support/namespace.h -@@ -66,7 +66,9 @@ struct support_chroot_configuration - { - /* File contents. The files are not created if the field is - NULL. */ -- const char *resolv_conf; -+ const char *resolv_conf; /* /etc/resolv.conf. */ -+ const char *hosts; /* /etc/hosts. */ -+ const char *host_conf; /* /etc/host.conf. */ - }; - - /* The result of the creation of a chroot. */ -@@ -78,8 +80,11 @@ struct support_chroot - /* Path to the chroot directory. */ - char *path_chroot; - -- /* Path to the /etc/resolv.conf file. */ -- char *path_resolv_conf; -+ /* Paths to files in the chroot. These are absolute and outside of -+ the chroot. */ -+ char *path_resolv_conf; /* /etc/resolv.conf. */ -+ char *path_hosts; /* /etc/hosts. */ -+ char *path_host_conf; /* /etc/host.conf. */ - }; - - /* Create a chroot environment. The returned data should be freed -diff --git a/support/support_chroot.c b/support/support_chroot.c -index c0807b313a..f3ef551b05 100644 ---- a/support/support_chroot.c -+++ b/support/support_chroot.c -@@ -24,6 +24,23 @@ - #include - #include - -+/* If CONTENTS is not NULL, write it to the file at DIRECTORY/RELPATH, -+ and store the name in *ABSPATH. If CONTENTS is NULL, store NULL in -+ *ABSPATH. */ -+static void -+write_file (const char *directory, const char *relpath, const char *contents, -+ char **abspath) -+{ -+ if (contents != NULL) -+ { -+ *abspath = xasprintf ("%s/%s", directory, relpath); -+ add_temp_file (*abspath); -+ support_write_file_string (*abspath, contents); -+ } -+ else -+ *abspath = NULL; -+} -+ - struct support_chroot * - support_chroot_create (struct support_chroot_configuration conf) - { -@@ -39,15 +56,10 @@ support_chroot_create (struct support_chroot_configuration conf) - xmkdir (path_etc, 0777); - add_temp_file (path_etc); - -- if (conf.resolv_conf != NULL) -- { -- /* Create an empty resolv.conf file. */ -- chroot->path_resolv_conf = xasprintf ("%s/resolv.conf", path_etc); -- add_temp_file (chroot->path_resolv_conf); -- support_write_file_string (chroot->path_resolv_conf, conf.resolv_conf); -- } -- else -- chroot->path_resolv_conf = NULL; -+ write_file (path_etc, "resolv.conf", conf.resolv_conf, -+ &chroot->path_resolv_conf); -+ write_file (path_etc, "hosts", conf.hosts, &chroot->path_hosts); -+ write_file (path_etc, "host.conf", conf.host_conf, &chroot->path_host_conf); - - free (path_etc); - -@@ -67,5 +79,7 @@ support_chroot_free (struct support_chroot *chroot) - { - free (chroot->path_chroot); - free (chroot->path_resolv_conf); -+ free (chroot->path_hosts); -+ free (chroot->path_host_conf); - free (chroot); - } - diff --git a/srcpkgs/glibc/patches/glibc-upstream-22.patch b/srcpkgs/glibc/patches/glibc-upstream-22.patch deleted file mode 100644 index d7d77db1d8..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-22.patch +++ /dev/null @@ -1,117 +0,0 @@ -From bdd8422cfb1fe04cb20617495156fb232b00d23c Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Fri, 1 Sep 2017 08:56:46 +0200 -Subject: [PATCH 22] getaddrinfo: Use &errno has the errno pointer - -Similar code in nss/getXXbyYY_r.c is already using &errno as the -argument. - -(cherry picked from commit 924b121c5978689001ae28cf1c8497371dad4f71) ---- - ChangeLog | 6 ++++++ - sysdeps/posix/getaddrinfo.c | 23 ++++++++++------------- - 2 files changed, 16 insertions(+), 13 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 591c753fcc..04304bb929 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-09-01 Florian Weimer -+ -+ * sysdeps/posix/getaddrinfo.c (gethosts): Use errno directly. -+ (getcanonname): Likewise. -+ (gaih_inet): Likewise. -+ - 2017-08-08 Florian Weimer - - * sysdeps/posix/getaddrinfo.c (gaih_inet): Remove unreachable -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 09f85fc472..1a16820b7e 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -247,11 +247,10 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - char *localcanon = NULL; \ - no_data = 0; \ - while (1) { \ -- rc = 0; \ - status = DL_CALL_FCT (fct, (name, _family, &th, \ - tmpbuf->data, tmpbuf->length, \ -- &rc, &herrno, NULL, &localcanon)); \ -- if (rc != ERANGE || herrno != NETDB_INTERNAL) \ -+ &errno, &herrno, NULL, &localcanon)); \ -+ if (errno != ERANGE || herrno != NETDB_INTERNAL) \ - break; \ - if (!scratch_buffer_grow (tmpbuf)) \ - { \ -@@ -261,11 +260,11 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - goto free_and_return; \ - } \ - } \ -- if (status == NSS_STATUS_SUCCESS && rc == 0) \ -+ if (status == NSS_STATUS_SUCCESS && errno == 0) \ - h = &th; \ - else \ - h = NULL; \ -- if (rc != 0) \ -+ if (errno != 0) \ - { \ - if (herrno == NETDB_INTERNAL) \ - { \ -@@ -335,9 +334,8 @@ getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name) - { - char buf[256]; - int herrno; -- int rc; - if (DL_CALL_FCT (cfct, (at->name ?: name, buf, sizeof (buf), -- &s, &rc, &herrno)) != NSS_STATUS_SUCCESS) -+ &s, &errno, &herrno)) != NSS_STATUS_SUCCESS) - /* If the canonical name cannot be determined, use the passed - string. */ - s = (char *) name; -@@ -353,7 +351,6 @@ gaih_inet (const char *name, const struct gaih_service *service, - const struct gaih_typeproto *tp = gaih_inet_typeproto; - struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv; - struct gaih_addrtuple *at = NULL; -- int rc; - bool got_ipv6 = false; - const char *canon = NULL; - const char *orig_name = name; -@@ -395,7 +392,8 @@ gaih_inet (const char *name, const struct gaih_service *service, - st = (struct gaih_servtuple *) - alloca_account (sizeof (struct gaih_servtuple), alloca_used); - -- if ((rc = gaih_inet_serv (service->name, tp, req, st, tmpbuf))) -+ int rc = gaih_inet_serv (service->name, tp, req, st, tmpbuf); -+ if (__glibc_unlikely (rc != 0)) - return rc; - } - else -@@ -495,7 +493,7 @@ gaih_inet (const char *name, const struct gaih_service *service, - idn_flags |= IDNA_USE_STD3_ASCII_RULES; - - char *p = NULL; -- rc = __idna_to_ascii_lz (name, &p, idn_flags); -+ int rc = __idna_to_ascii_lz (name, &p, idn_flags); - if (rc != IDNA_SUCCESS) - { - /* No need to jump to free_and_return here. */ -@@ -793,15 +791,14 @@ gaih_inet (const char *name, const struct gaih_service *service, - - while (1) - { -- rc = 0; - status = DL_CALL_FCT (fct4, (name, pat, - tmpbuf->data, tmpbuf->length, -- &rc, &herrno, -+ &errno, &herrno, - NULL)); - if (status == NSS_STATUS_SUCCESS) - break; - if (status != NSS_STATUS_TRYAGAIN -- || rc != ERANGE || herrno != NETDB_INTERNAL) -+ || errno != ERANGE || herrno != NETDB_INTERNAL) - { - if (herrno == TRY_AGAIN) - no_data = EAI_AGAIN; - diff --git a/srcpkgs/glibc/patches/glibc-upstream-23.patch b/srcpkgs/glibc/patches/glibc-upstream-23.patch deleted file mode 100644 index ad63bf8868..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-23.patch +++ /dev/null @@ -1,171 +0,0 @@ -From 701f7873da013fb19d9120317322cd78333e63c2 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Fri, 1 Sep 2017 08:57:07 +0200 -Subject: [PATCH 23] getaddrinfo: Use &h_errno has the h_errno pointer - -This simplifies the code because it is not necessary to propagate the -temporary h_errno value to the thread-local variable. It also increases -compatibility with NSS modules which update only one of the two places. - -(cherry picked from commit 53250a21b81474ef4e78090a4a9a63d8471e1091) ---- - ChangeLog | 6 ++++++ - sysdeps/posix/getaddrinfo.c | 46 ++++++++++++++++++--------------------------- - 2 files changed, 24 insertions(+), 28 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 04304bb929..d53c8fe083 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,11 @@ - 2017-09-01 Florian Weimer - -+ * sysdeps/posix/getaddrinfo.c (gethosts): Use h_errno directly. -+ (getcanonname): Likewise. -+ (gaih_inet): Likewise. -+ -+2017-09-01 Florian Weimer -+ - * sysdeps/posix/getaddrinfo.c (gethosts): Use errno directly. - (getcanonname): Likewise. - (gaih_inet): Likewise. -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 1a16820b7e..076e1fa62b 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -241,7 +241,6 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - - #define gethosts(_family, _type) \ - { \ -- int herrno; \ - struct hostent th; \ - struct hostent *h; \ - char *localcanon = NULL; \ -@@ -249,8 +248,8 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - while (1) { \ - status = DL_CALL_FCT (fct, (name, _family, &th, \ - tmpbuf->data, tmpbuf->length, \ -- &errno, &herrno, NULL, &localcanon)); \ -- if (errno != ERANGE || herrno != NETDB_INTERNAL) \ -+ &errno, &h_errno, NULL, &localcanon)); \ -+ if (errno != ERANGE || h_errno != NETDB_INTERNAL) \ - break; \ - if (!scratch_buffer_grow (tmpbuf)) \ - { \ -@@ -266,18 +265,17 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - h = NULL; \ - if (errno != 0) \ - { \ -- if (herrno == NETDB_INTERNAL) \ -+ if (h_errno == NETDB_INTERNAL) \ - { \ -- __set_h_errno (herrno); \ - __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); \ - __resolv_context_put (res_ctx); \ - result = -EAI_SYSTEM; \ - goto free_and_return; \ - } \ -- if (herrno == TRY_AGAIN) \ -+ if (h_errno == TRY_AGAIN) \ - no_data = EAI_AGAIN; \ - else \ -- no_data = herrno == NO_DATA; \ -+ no_data = h_errno == NO_DATA; \ - } \ - else if (h != NULL) \ - { \ -@@ -333,9 +331,8 @@ getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name) - if (cfct != NULL) - { - char buf[256]; -- int herrno; - if (DL_CALL_FCT (cfct, (at->name ?: name, buf, sizeof (buf), -- &s, &errno, &herrno)) != NSS_STATUS_SUCCESS) -+ &s, &errno, &h_errno)) != NSS_STATUS_SUCCESS) - /* If the canonical name cannot be determined, use the passed - string. */ - s = (char *) name; -@@ -594,14 +591,13 @@ gaih_inet (const char *name, const struct gaih_service *service, - int rc; - struct hostent th; - struct hostent *h; -- int herrno; - - while (1) - { - rc = __gethostbyname2_r (name, AF_INET, &th, - tmpbuf->data, tmpbuf->length, -- &h, &herrno); -- if (rc != ERANGE || herrno != NETDB_INTERNAL) -+ &h, &h_errno); -+ if (rc != ERANGE || h_errno != NETDB_INTERNAL) - break; - if (!scratch_buffer_grow (tmpbuf)) - { -@@ -626,12 +622,9 @@ gaih_inet (const char *name, const struct gaih_service *service, - } - else - { -- if (herrno == NETDB_INTERNAL) -- { -- __set_h_errno (herrno); -- result = -EAI_SYSTEM; -- } -- else if (herrno == TRY_AGAIN) -+ if (h_errno == NETDB_INTERNAL) -+ result = -EAI_SYSTEM; -+ else if (h_errno == TRY_AGAIN) - result = -EAI_AGAIN; - else - /* We made requests but they turned out no data. -@@ -654,8 +647,7 @@ gaih_inet (const char *name, const struct gaih_service *service, - { - /* Try to use nscd. */ - struct nscd_ai_result *air = NULL; -- int herrno; -- int err = __nscd_getai (name, &air, &herrno); -+ int err = __nscd_getai (name, &air, &h_errno); - if (air != NULL) - { - /* Transform into gaih_addrtuple list. */ -@@ -746,9 +738,9 @@ gaih_inet (const char *name, const struct gaih_service *service, - goto free_and_return; - else if (__nss_not_use_nscd_hosts == 0) - { -- if (herrno == NETDB_INTERNAL && errno == ENOMEM) -+ if (h_errno == NETDB_INTERNAL && errno == ENOMEM) - result = -EAI_MEMORY; -- else if (herrno == TRY_AGAIN) -+ else if (h_errno == TRY_AGAIN) - result = -EAI_AGAIN; - else - result = -EAI_SYSTEM; -@@ -787,23 +779,21 @@ gaih_inet (const char *name, const struct gaih_service *service, - - if (fct4 != NULL) - { -- int herrno; -- - while (1) - { - status = DL_CALL_FCT (fct4, (name, pat, - tmpbuf->data, tmpbuf->length, -- &errno, &herrno, -+ &errno, &h_errno, - NULL)); - if (status == NSS_STATUS_SUCCESS) - break; - if (status != NSS_STATUS_TRYAGAIN -- || errno != ERANGE || herrno != NETDB_INTERNAL) -+ || errno != ERANGE || h_errno != NETDB_INTERNAL) - { -- if (herrno == TRY_AGAIN) -+ if (h_errno == TRY_AGAIN) - no_data = EAI_AGAIN; - else -- no_data = herrno == NO_DATA; -+ no_data = h_errno == NO_DATA; - break; - } - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-24.patch b/srcpkgs/glibc/patches/glibc-upstream-24.patch deleted file mode 100644 index 45ab37f87e..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-24.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 8f46c6052408a23a77ecf46aa378120c1a4afe37 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Fri, 1 Sep 2017 08:57:28 +0200 -Subject: [PATCH 24] getaddrinfo: Properly set errno for NSS function lookup - failure - -(cherry picked from commit ad816a5e00ce891a2cea8187638fa0e00f83aaf6) ---- - ChangeLog | 5 +++++ - sysdeps/posix/getaddrinfo.c | 16 ++++++++++------ - 2 files changed, 15 insertions(+), 6 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index d53c8fe083..2f959d4c36 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,10 @@ - 2017-09-01 Florian Weimer - -+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Make reporting of NSS -+ function lookup failures more reliable. -+ -+2017-09-01 Florian Weimer -+ - * sysdeps/posix/getaddrinfo.c (gethosts): Use h_errno directly. - (getcanonname): Likewise. - (gaih_inet): Likewise. -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 076e1fa62b..eaf8bafcf4 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -923,13 +923,17 @@ gaih_inet (const char *name, const struct gaih_service *service, - } - else - { -+ /* Could not locate any of the lookup functions. -+ The NSS lookup code does not consistently set -+ errno, so we need to supply our own error -+ code here. The root cause could either be a -+ resource allocation failure, or a missing -+ service function in the DSO (so it should not -+ be listed in /etc/nsswitch.conf). Assume the -+ former, and return EBUSY. */ - status = NSS_STATUS_UNAVAIL; -- /* Could not load any of the lookup functions. Indicate -- an internal error if the failure was due to a system -- error other than the file not being found. We use the -- errno from the last failed callback. */ -- if (errno != 0 && errno != ENOENT) -- __set_h_errno (NETDB_INTERNAL); -+ __set_h_errno (NETDB_INTERNAL); -+ __set_errno (EBUSY); - } - } - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-25.patch b/srcpkgs/glibc/patches/glibc-upstream-25.patch deleted file mode 100644 index 20ae088f50..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-25.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 7ab87bccb657b02cac5a3360b11c67aff901de2e Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Fri, 1 Sep 2017 08:57:52 +0200 -Subject: [PATCH 25] getaddrinfo: In gaih_inet, use h_errno for certain - status values only - -h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be -accurate at this point. - -(cherry picked from commit a2881ef01450295782b065f2f850f340d5c12c14) ---- - ChangeLog | 5 +++++ - sysdeps/posix/getaddrinfo.c | 5 ++++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 2f959d4c36..c58cd5ccd0 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,10 @@ - 2017-09-01 Florian Weimer - -+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Only use h_errno if -+ status indicates it is set. -+ -+2017-09-01 Florian Weimer -+ - * sysdeps/posix/getaddrinfo.c (gaih_inet): Make reporting of NSS - function lookup failures more reliable. - -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index eaf8bafcf4..9d9e7e2bf2 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -949,7 +949,10 @@ gaih_inet (const char *name, const struct gaih_service *service, - __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); - __resolv_context_put (res_ctx); - -- if (h_errno == NETDB_INTERNAL) -+ /* If we have a failure which sets errno, report it using -+ EAI_SYSTEM. */ -+ if ((status == NSS_STATUS_TRYAGAIN || status == NSS_STATUS_UNAVAIL) -+ && h_errno == NETDB_INTERNAL) - { - result = -EAI_SYSTEM; - goto free_and_return; - diff --git a/srcpkgs/glibc/patches/glibc-upstream-26.patch b/srcpkgs/glibc/patches/glibc-upstream-26.patch deleted file mode 100644 index cd525009f6..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-26.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 7966331555df43bb7e2a55ce5a17a330e57f487f Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Mon, 4 Sep 2017 11:25:34 +0200 -Subject: [PATCH 26] getaddrinfo: Return EAI_NODATA if gethostbyname2_r - reports NO_DATA [BZ #21922] - -(cherry picked from commit 5f8340f583fe3d4f5734bd2371c5a45ecff2db0d) ---- - ChangeLog | 6 ++++++ - NEWS | 1 + - sysdeps/posix/getaddrinfo.c | 8 ++++++++ - 3 files changed, 15 insertions(+) - -diff --git a/ChangeLog b/ChangeLog -index c58cd5ccd0..f46bbb7c0d 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,11 @@ - 2017-09-01 Florian Weimer - -+ [BZ #21922] -+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Report EAI_NODATA error -+ coming from gethostbyname2_r. -+ -+2017-09-01 Florian Weimer -+ - * sysdeps/posix/getaddrinfo.c (gaih_inet): Only use h_errno if - status indicates it is set. - -diff --git a/NEWS b/NEWS -index 756e849643..97eb21e868 100644 ---- a/NEWS -+++ b/NEWS -@@ -22,6 +22,7 @@ The following bugs are resolved with this release: - [21780] posix: Set p{read,write}v2 to return ENOTSUP - [21871] x86-64: Use _dl_runtime_resolve_opt only with AVX512F - [21885] getaddrinfo: Release resolver context on error in gethosts -+ [21922] getaddrinfo with AF_INET(6) returns EAI_NONAME, not EAI_NODATA - [21930] Do not use __builtin_types_compatible_p in C++ mode - [21932] Unpaired __resolv_context_get in generic get*_r implementation - [21941] powerpc: Restrict xssqrtqp operands to Vector Registers -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 9d9e7e2bf2..0cf87c224d 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -619,6 +619,14 @@ gaih_inet (const char *name, const struct gaih_service *service, - } - *pat = addrmem; - } -+ else -+ { -+ if (h_errno == NO_DATA) -+ result = -EAI_NODATA; -+ else -+ result = -EAI_NONAME; -+ goto free_and_return; -+ } - } - else - { - diff --git a/srcpkgs/glibc/patches/glibc-upstream-27.patch b/srcpkgs/glibc/patches/glibc-upstream-27.patch deleted file mode 100644 index 43db6c7a34..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-27.patch +++ /dev/null @@ -1,376 +0,0 @@ -From a71a3374cd8cf53776c33994f69ec184c26f2129 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Mon, 4 Sep 2017 11:27:24 +0200 -Subject: [PATCH 27] getaddrinfo: Fix error handling in gethosts [BZ #21915] - [BZ #21922] - -The old code uses errno as the primary indicator for success or -failure. This is wrong because errno is only set for specific -combinations of the status return value and the h_errno variable. - -(cherry picked from commit f4a6be2582b8dfe8adfa68da3dd8decf566b3983) ---- - ChangeLog | 14 +++++ - NEWS | 1 + - nss/Makefile | 7 +++ - nss/tst-nss-files-hosts-erange.c | 109 +++++++++++++++++++++++++++++++++++++++ - resolv/tst-resolv-basic.c | 78 +++++++++++++++++++--------- - sysdeps/posix/getaddrinfo.c | 42 +++++++-------- - 6 files changed, 206 insertions(+), 45 deletions(-) - create mode 100644 nss/tst-nss-files-hosts-erange.c - -diff --git a/ChangeLog b/ChangeLog -index f46bbb7c0d..3e32d14dbf 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,19 @@ - 2017-09-01 Florian Weimer - -+ [BZ #21915] -+ [BZ #21922] -+ * sysdeps/posix/getaddrinfo.c (gethosts): Look at NSS function -+ result to determine success or failure, not the errno value. -+ * nss/Makefile (tests): Add tst-nss-files-hosts-erange. -+ (tst-nss-files-hosts-erange): Link with -ldl. -+ * nss/tst-nss-files-hosts-erange.c: New file. -+ * nss/tst-resolv-basic.c (response): Handle nodata.example. -+ (do_test): Add NO_DATA tests. -+ * resolv/tst-resolv-basic.c (test_nodata_nxdomain): New function. -+ (do_test): Call it. -+ -+2017-09-01 Florian Weimer -+ - [BZ #21922] - * sysdeps/posix/getaddrinfo.c (gaih_inet): Report EAI_NODATA error - coming from gethostbyname2_r. -diff --git a/NEWS b/NEWS -index 97eb21e868..8fbf4241d1 100644 ---- a/NEWS -+++ b/NEWS -@@ -22,6 +22,7 @@ The following bugs are resolved with this release: - [21780] posix: Set p{read,write}v2 to return ENOTSUP - [21871] x86-64: Use _dl_runtime_resolve_opt only with AVX512F - [21885] getaddrinfo: Release resolver context on error in gethosts -+ [21915] getaddrinfo: incorrect result handling for NSS service modules - [21922] getaddrinfo with AF_INET(6) returns EAI_NONAME, not EAI_NODATA - [21930] Do not use __builtin_types_compatible_p in C++ mode - [21932] Unpaired __resolv_context_get in generic get*_r implementation -diff --git a/nss/Makefile b/nss/Makefile -index d9f6d41181..91b1c21567 100644 ---- a/nss/Makefile -+++ b/nss/Makefile -@@ -58,6 +58,11 @@ tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \ - tst-nss-test5 - xtests = bug-erange - -+# Tests which need libdl -+ifeq (yes,$(build-shared)) -+tests += tst-nss-files-hosts-erange -+endif -+ - # If we have a thread library then we can test cancellation against - # some routines like getpwuid_r. - ifeq (yes,$(have-thread-library)) -@@ -154,3 +159,5 @@ $(patsubst %,$(objpfx)%.out,$(tests)) : \ - ifeq (yes,$(have-thread-library)) - $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) - endif -+ -+$(objpfx)tst-nss-files-hosts-erange: $(libdl) -diff --git a/nss/tst-nss-files-hosts-erange.c b/nss/tst-nss-files-hosts-erange.c -new file mode 100644 -index 0000000000..beb7aa9fa0 ---- /dev/null -+++ b/nss/tst-nss-files-hosts-erange.c -@@ -0,0 +1,109 @@ -+/* Parse /etc/hosts in multi mode with a trailing long line (bug 21915). -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+struct support_chroot *chroot_env; -+ -+#define X10 "XXXXXXXXXX" -+#define X100 X10 X10 X10 X10 X10 X10 X10 X10 X10 X10 -+#define X1000 X100 X100 X100 X100 X100 X100 X100 X100 X100 X100 -+ -+static void -+prepare (int argc, char **argv) -+{ -+ chroot_env = support_chroot_create -+ ((struct support_chroot_configuration) -+ { -+ .resolv_conf = "", -+ .hosts = -+ "127.0.0.1 localhost localhost.localdomain\n" -+ "::1 localhost localhost.localdomain\n" -+ "192.0.2.1 example.com\n" -+ "#" X1000 X100 "\n", -+ .host_conf = "multi on\n", -+ }); -+} -+ -+static int -+do_test (void) -+{ -+ support_become_root (); -+ if (!support_can_chroot ()) -+ return EXIT_UNSUPPORTED; -+ -+ __nss_configure_lookup ("hosts", "files"); -+ if (dlopen (LIBNSS_FILES_SO, RTLD_LAZY) == NULL) -+ FAIL_EXIT1 ("could not load " LIBNSS_DNS_SO ": %s", dlerror ()); -+ -+ xchroot (chroot_env->path_chroot); -+ -+ errno = ERANGE; -+ h_errno = NETDB_INTERNAL; -+ check_hostent ("gethostbyname example.com", -+ gethostbyname ("example.com"), -+ "name: example.com\n" -+ "address: 192.0.2.1\n"); -+ errno = ERANGE; -+ h_errno = NETDB_INTERNAL; -+ check_hostent ("gethostbyname2 AF_INET example.com", -+ gethostbyname2 ("example.com", AF_INET), -+ "name: example.com\n" -+ "address: 192.0.2.1\n"); -+ { -+ struct addrinfo hints = -+ { -+ .ai_family = AF_UNSPEC, -+ .ai_socktype = SOCK_STREAM, -+ .ai_protocol = IPPROTO_TCP, -+ }; -+ errno = ERANGE; -+ h_errno = NETDB_INTERNAL; -+ struct addrinfo *ai; -+ int ret = getaddrinfo ("example.com", "80", &hints, &ai); -+ check_addrinfo ("example.com AF_UNSPEC", ai, ret, -+ "address: STREAM/TCP 192.0.2.1 80\n"); -+ if (ret == 0) -+ freeaddrinfo (ai); -+ -+ hints.ai_family = AF_INET; -+ errno = ERANGE; -+ h_errno = NETDB_INTERNAL; -+ ret = getaddrinfo ("example.com", "80", &hints, &ai); -+ check_addrinfo ("example.com AF_INET", ai, ret, -+ "address: STREAM/TCP 192.0.2.1 80\n"); -+ if (ret == 0) -+ freeaddrinfo (ai); -+ } -+ -+ support_chroot_free (chroot_env); -+ return 0; -+} -+ -+#define PREPARE prepare -+#include -diff --git a/resolv/tst-resolv-basic.c b/resolv/tst-resolv-basic.c -index 64eedbbd81..66a0e8a165 100644 ---- a/resolv/tst-resolv-basic.c -+++ b/resolv/tst-resolv-basic.c -@@ -50,7 +50,7 @@ response (const struct resolv_response_context *ctx, - qname_compare = qname + 2; - else - qname_compare = qname; -- enum {www, alias, nxdomain, long_name} requested_qname; -+ enum {www, alias, nxdomain, long_name, nodata} requested_qname; - if (strcmp (qname_compare, "www.example") == 0) - requested_qname = www; - else if (strcmp (qname_compare, "alias.example") == 0) -@@ -59,6 +59,8 @@ response (const struct resolv_response_context *ctx, - requested_qname = nxdomain; - else if (strcmp (qname_compare, LONG_NAME) == 0) - requested_qname = long_name; -+ else if (strcmp (qname_compare, "nodata.example") == 0) -+ requested_qname = nodata; - else - { - support_record_failure (); -@@ -87,6 +89,8 @@ response (const struct resolv_response_context *ctx, - resolv_response_close_record (b); - resolv_response_open_record (b, "www.example", qclass, qtype, 0); - break; -+ case nodata: -+ return; - case nxdomain: - FAIL_EXIT1 ("unreachable"); - } -@@ -267,6 +271,55 @@ test_bug_21295 (void) - } - } - -+/* Run tests which do not expect any data. */ -+static void -+test_nodata_nxdomain (void) -+{ -+ /* Iterate through different address families. */ -+ int families[] = { AF_UNSPEC, AF_INET, AF_INET6, -1 }; -+ for (int i = 0; families[i] >= 0; ++i) -+ /* If do_tcp, prepend "t." to the name to trigger TCP -+ fallback. */ -+ for (int do_tcp = 0; do_tcp < 2; ++do_tcp) -+ /* If do_nxdomain, trigger an NXDOMAIN error (DNS failure), -+ otherwise use a NODATA response (empty but successful -+ answer). */ -+ for (int do_nxdomain = 0; do_nxdomain < 2; ++do_nxdomain) -+ { -+ int family = families[i]; -+ char *name = xasprintf ("%s%s.example", -+ do_tcp ? "t." : "", -+ do_nxdomain ? "nxdomain" : "nodata"); -+ -+ if (family != AF_UNSPEC) -+ { -+ if (do_nxdomain) -+ check_h (name, family, "error: HOST_NOT_FOUND\n"); -+ else -+ check_h (name, family, "error: NO_ADDRESS\n"); -+ } -+ -+ const char *expected; -+ if (do_nxdomain) -+ expected = "error: Name or service not known\n"; -+ else -+ expected = "error: No address associated with hostname\n"; -+ -+ check_ai (name, "80", family, expected); -+ -+ struct addrinfo hints = -+ { -+ .ai_family = family, -+ .ai_flags = AI_V4MAPPED | AI_ALL, -+ }; -+ check_ai_hints (name, "80", hints, expected); -+ hints.ai_flags |= AI_CANONNAME; -+ check_ai_hints (name, "80", hints, expected); -+ -+ free (name); -+ } -+} -+ - static int - do_test (void) - { -@@ -439,29 +492,8 @@ do_test (void) - "address: DGRAM/UDP 2001:db8::4 80\n" - "address: RAW/IP 2001:db8::4 80\n"); - -- check_h ("nxdomain.example", AF_INET, -- "error: HOST_NOT_FOUND\n"); -- check_h ("nxdomain.example", AF_INET6, -- "error: HOST_NOT_FOUND\n"); -- check_ai ("nxdomain.example", "80", AF_UNSPEC, -- "error: Name or service not known\n"); -- check_ai ("nxdomain.example", "80", AF_INET, -- "error: Name or service not known\n"); -- check_ai ("nxdomain.example", "80", AF_INET6, -- "error: Name or service not known\n"); -- -- check_h ("t.nxdomain.example", AF_INET, -- "error: HOST_NOT_FOUND\n"); -- check_h ("t.nxdomain.example", AF_INET6, -- "error: HOST_NOT_FOUND\n"); -- check_ai ("t.nxdomain.example", "80", AF_UNSPEC, -- "error: Name or service not known\n"); -- check_ai ("t.nxdomain.example", "80", AF_INET, -- "error: Name or service not known\n"); -- check_ai ("t.nxdomain.example", "80", AF_INET6, -- "error: Name or service not known\n"); -- - test_bug_21295 (); -+ test_nodata_nxdomain (); - - resolv_test_end (aux); - -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index 0cf87c224d..2c4b6d6793 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -242,28 +242,26 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - #define gethosts(_family, _type) \ - { \ - struct hostent th; \ -- struct hostent *h; \ - char *localcanon = NULL; \ - no_data = 0; \ -- while (1) { \ -- status = DL_CALL_FCT (fct, (name, _family, &th, \ -- tmpbuf->data, tmpbuf->length, \ -- &errno, &h_errno, NULL, &localcanon)); \ -- if (errno != ERANGE || h_errno != NETDB_INTERNAL) \ -- break; \ -- if (!scratch_buffer_grow (tmpbuf)) \ -- { \ -- __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); \ -- __resolv_context_put (res_ctx); \ -- result = -EAI_MEMORY; \ -- goto free_and_return; \ -- } \ -- } \ -- if (status == NSS_STATUS_SUCCESS && errno == 0) \ -- h = &th; \ -- else \ -- h = NULL; \ -- if (errno != 0) \ -+ while (1) \ -+ { \ -+ status = DL_CALL_FCT (fct, (name, _family, &th, \ -+ tmpbuf->data, tmpbuf->length, \ -+ &errno, &h_errno, NULL, &localcanon)); \ -+ if (status != NSS_STATUS_TRYAGAIN || h_errno != NETDB_INTERNAL \ -+ || errno != ERANGE) \ -+ break; \ -+ if (!scratch_buffer_grow (tmpbuf)) \ -+ { \ -+ __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); \ -+ __resolv_context_put (res_ctx); \ -+ result = -EAI_MEMORY; \ -+ goto free_and_return; \ -+ } \ -+ } \ -+ if (status == NSS_STATUS_NOTFOUND \ -+ || status == NSS_STATUS_TRYAGAIN || status == NSS_STATUS_UNAVAIL) \ - { \ - if (h_errno == NETDB_INTERNAL) \ - { \ -@@ -277,9 +275,9 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, - else \ - no_data = h_errno == NO_DATA; \ - } \ -- else if (h != NULL) \ -+ else if (status == NSS_STATUS_SUCCESS) \ - { \ -- if (!convert_hostent_to_gaih_addrtuple (req, _family,h, &addrmem)) \ -+ if (!convert_hostent_to_gaih_addrtuple (req, _family, &th, &addrmem)) \ - { \ - __resolv_context_enable_inet6 (res_ctx, res_enable_inet6); \ - __resolv_context_put (res_ctx); \ - diff --git a/srcpkgs/glibc/patches/glibc-upstream-28.patch b/srcpkgs/glibc/patches/glibc-upstream-28.patch deleted file mode 100644 index 4fd42d3437..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-28.patch +++ /dev/null @@ -1,346 +0,0 @@ -From 85cfe508568530eed2d9cfd34110c21721d1f99e Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 6 Sep 2017 13:43:01 +0200 -Subject: [PATCH 28] tst-res_use_inet6: Enhance test to cover IPv4-to-IPv6 - address mapping - -This requires more control over the response data, so it is now -determined by flags embedded in the query name. - -(cherry picked from commit 5e9c4d17feb9910f489ad2915d0b6e00597a0f11) ---- - ChangeLog | 12 +++ - resolv/tst-res_use_inet6.c | 231 ++++++++++++++++++++++++++++++++++++--------- - 2 files changed, 198 insertions(+), 45 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 3e32d14dbf..dd71f6c427 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,15 @@ -+2017-09-06 Florian Weimer -+ -+ Enhance tst-res_use_inet6 to test IPv4-to-IPv6 address mapping. -+ * resolv/tst-res_use_inet6.c (response): Process flags embedded in -+ the QNAME. -+ (test_gai): Adjust query names. Add additional tests. -+ (test_get2_any, test_get2_no_inet6, test_get2_inet6): Split from -+ test_get2. Adjust query names. Add additional tests. -+ (test_no_inet6): New function, extracted from threadfunc. -+ (threadfunc): Call test_get2_any, test_get2_inet6, test_no_inet6. -+ Add additional tests. -+ - 2017-09-01 Florian Weimer - - [BZ #21915] -diff --git a/resolv/tst-res_use_inet6.c b/resolv/tst-res_use_inet6.c -index 6f3db08892..1522d5c5f5 100644 ---- a/resolv/tst-res_use_inet6.c -+++ b/resolv/tst-res_use_inet6.c -@@ -19,18 +19,44 @@ - #include - #include - #include -+#include - #include - #include - #include - -+/* Produce a response based on QNAME: Certain characters in the first -+ label of QNAME trigger the inclusion of resource records: -+ -+ 'a' A record (IPv4 address) -+ 'q' AAAA record (quad A record, IPv6 address) -+ 'm' record type must match QTYPE (no additional records) -+ -+ QTYPE is ignored for record type selection if 'm' is not -+ specified. */ - static void - response (const struct resolv_response_context *ctx, - struct resolv_response_builder *b, - const char *qname, uint16_t qclass, uint16_t qtype) - { -- bool include_both = strcmp (qname, "both.example") == 0; -- bool include_a = qtype == T_A || include_both; -- bool include_aaaa = qtype == T_AAAA || include_both; -+ bool include_a = false; -+ bool include_aaaa = false; -+ bool include_match = false; -+ for (const char *p = qname; *p != '.' && *p != '\0'; ++p) -+ { -+ if (*p == 'a') -+ include_a = true; -+ else if (*p == 'q') -+ include_aaaa = true; -+ else if (*p == 'm') -+ include_match = true; -+ } -+ if (include_match) -+ { -+ if (qtype == T_A) -+ include_aaaa = false; -+ else if (qtype == T_AAAA) -+ include_a = false; -+ } - - resolv_response_init (b, (struct resolv_response_flags) {}); - resolv_response_add_question (b, qname, qclass, qtype); -@@ -64,16 +90,21 @@ test_gai (void) - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; -- int ret = getaddrinfo ("www1.example", "80", &hints, &ai); -- check_addrinfo ("getaddrinfo AF_UNSPEC www1.example", ai, ret, -+ int ret = getaddrinfo ("qam.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_UNSPEC qam.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); -- ret = getaddrinfo ("both.example", "80", &hints, &ai); -+ ret = getaddrinfo ("am.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_UNSPEC am.example", ai, ret, -+ "address: STREAM/TCP 192.0.2.17 80\n"); -+ if (ret == 0) -+ freeaddrinfo (ai); -+ ret = getaddrinfo ("qa.example", "80", &hints, &ai); - /* Combined A/AAAA responses currently result in address - duplication. */ -- check_addrinfo ("getaddrinfo AF_UNSPEC both.example", ai, ret, -+ check_addrinfo ("getaddrinfo AF_UNSPEC qa.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 2001:db8::1 80\n" -@@ -89,13 +120,18 @@ test_gai (void) - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; -- int ret = getaddrinfo ("www1.example", "80", &hints, &ai); -- check_addrinfo ("getaddrinfo AF_INET www1.example", ai, ret, -+ int ret = getaddrinfo ("qam.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_INET qam.example", ai, ret, -+ "address: STREAM/TCP 192.0.2.17 80\n"); -+ if (ret == 0) -+ freeaddrinfo (ai); -+ ret = getaddrinfo ("am.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_INET am.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); -- ret = getaddrinfo ("both.example", "80", &hints, &ai); -- check_addrinfo ("getaddrinfo AF_INET both.example", ai, ret, -+ ret = getaddrinfo ("qa.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_INET qa.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); -@@ -108,40 +144,131 @@ test_gai (void) - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; -- int ret = getaddrinfo ("www1.example", "80", &hints, &ai); -+ int ret = getaddrinfo ("qa.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo (AF_INET6)", ai, ret, - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); -- ret = getaddrinfo ("both.example", "80", &hints, &ai); -- check_addrinfo ("getaddrinfo AF_INET6 both.example", ai, ret, -+ ret = getaddrinfo ("am.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_INET6 am.example", ai, ret, -+ "error: No address associated with hostname\n"); -+ if (ret == 0) -+ freeaddrinfo (ai); -+ ret = getaddrinfo ("qam.example", "80", &hints, &ai); -+ check_addrinfo ("getaddrinfo AF_INET6 qam.example", ai, ret, - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); - } - } - --/* Test that gethostbyname2 is not influenced by RES_USE_INET6. */ -+/* Test that gethostbyname2 is mostly not influenced by -+ RES_USE_INET6. */ - static void --test_get2 (void) -+test_get2_any (void) - { -- check_hostent ("gethostbyname2 AF_INET www1.example", -- gethostbyname2 ("www1.example", AF_INET), -- "name: www1.example\n" -+ check_hostent ("gethostbyname2 AF_INET am.example", -+ gethostbyname2 ("am.example", AF_INET), -+ "name: am.example\n" - "address: 192.0.2.17\n"); -- check_hostent ("gethostbyname2 AF_INET both.example", -- gethostbyname2 ("both.example", AF_INET), -- "name: both.example\n" -+ check_hostent ("gethostbyname2 AF_INET a.example", -+ gethostbyname2 ("a.example", AF_INET), -+ "name: a.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname2 AF_INET qm.example", -+ gethostbyname2 ("qm.example", AF_INET), -+ "error: NO_ADDRESS\n"); -+ check_hostent ("gethostbyname2 AF_INET q.example", -+ gethostbyname2 ("q.example", AF_INET), -+ "error: NO_RECOVERY\n"); -+ check_hostent ("gethostbyname2 AF_INET qam.example", -+ gethostbyname2 ("qam.example", AF_INET), -+ "name: qam.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname2 AF_INET qa.example", -+ gethostbyname2 ("qa.example", AF_INET), -+ "name: qa.example\n" - "address: 192.0.2.17\n"); - -- check_hostent ("gethostbyname2 AF_INET6 www1.example", -- gethostbyname2 ("www1.example", AF_INET6), -- "name: www1.example\n" -+ check_hostent ("gethostbyname2 AF_INET6 qm.example", -+ gethostbyname2 ("qm.example", AF_INET6), -+ "name: qm.example\n" -+ "address: 2001:db8::1\n"); -+ check_hostent ("gethostbyname2 AF_INET6 q.example", -+ gethostbyname2 ("q.example", AF_INET6), -+ "name: q.example\n" - "address: 2001:db8::1\n"); -- check_hostent ("gethostbyname2 AF_INET6 both.example", -- gethostbyname2 ("both.example", AF_INET6), -- "name: both.example\n" -+ check_hostent ("gethostbyname2 AF_INET6 qam.example", -+ gethostbyname2 ("qam.example", AF_INET6), -+ "name: qam.example\n" - "address: 2001:db8::1\n"); -+ check_hostent ("gethostbyname2 AF_INET6 qa.example", -+ gethostbyname2 ("qa.example", AF_INET6), -+ "name: qa.example\n" -+ "address: 2001:db8::1\n"); -+ /* Additional AF_INET6 tests depend on RES_USE_INET6; see below. */ -+} -+ -+/* gethostbyname2 tests with RES_USE_INET6 disabled. */ -+static void -+test_get2_no_inet6 (void) -+{ -+ test_get2_any (); -+ -+ check_hostent ("gethostbyname2 AF_INET6 am.example", -+ gethostbyname2 ("am.example", AF_INET6), -+ "error: NO_ADDRESS\n"); -+ check_hostent ("gethostbyname2 AF_INET6 a.example", -+ gethostbyname2 ("a.example", AF_INET6), -+ "error: NO_RECOVERY\n"); -+} -+ -+/* gethostbyname2 tests with RES_USE_INET6 enabled. */ -+static void -+test_get2_inet6 (void) -+{ -+ test_get2_any (); -+ -+ check_hostent ("gethostbyname2 AF_INET6 am.example", -+ gethostbyname2 ("am.example", AF_INET6), -+ "name: am.example\n" -+ "address: ::ffff:192.0.2.17\n"); -+ check_hostent ("gethostbyname2 AF_INET6 a.example", -+ gethostbyname2 ("a.example", AF_INET6), -+ "error: NO_RECOVERY\n"); -+} -+ -+/* Collection of tests which assume no RES_USE_INET6 flag. */ -+static void -+test_no_inet6 (void) -+{ -+ check_hostent ("gethostbyname (\"a.example\")", -+ gethostbyname ("a.example"), -+ "name: a.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"qa.example\")", -+ gethostbyname ("qa.example"), -+ "name: qa.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"am.example\")", -+ gethostbyname ("am.example"), -+ "name: am.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"qam.example\")", -+ gethostbyname ("qam.example"), -+ "name: qam.example\n" -+ "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"q.example\")", -+ gethostbyname ("q.example"), -+ "error: NO_RECOVERY\n"); -+ check_hostent ("gethostbyname (\"qm.example\")", -+ gethostbyname ("qm.example"), -+ "error: NO_ADDRESS\n"); -+ test_get2_no_inet6 (); -+ test_get2_no_inet6 (); -+ test_gai (); -+ test_get2_no_inet6 (); -+ test_get2_no_inet6 (); - } - - static void * -@@ -153,28 +280,42 @@ threadfunc (void *ignored) - .response_callback = response - }); - -- check_hostent ("gethostbyname (\"www1.example\")", -- gethostbyname ("www1.example"), -- "name: www1.example\n" -- "address: 192.0.2.17\n"); -- check_hostent ("gethostbyname (\"both.example\")", -- gethostbyname ("both.example"), -- "name: both.example\n" -- "address: 192.0.2.17\n"); -- test_get2 (); -- test_gai (); -+ TEST_VERIFY ((_res.options & RES_USE_INET6) == 0); -+ test_no_inet6 (); - - _res.options |= RES_USE_INET6; -- check_hostent ("gethostbyname (\"www1.example\")", -- gethostbyname ("www1.example"), -- "name: www1.example\n" -+ check_hostent ("gethostbyname (\"a.inet6.example\")", -+ gethostbyname ("a.inet6.example"), -+ "error: NO_RECOVERY\n"); -+ check_hostent ("gethostbyname (\"am.inet6.example\")", -+ gethostbyname ("am.inet6.example"), -+ "name: am.inet6.example\n" -+ "address: ::ffff:192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"qa.inet6.example\")", -+ gethostbyname ("qa.inet6.example"), -+ "name: qa.inet6.example\n" -+ "address: 2001:db8::1\n"); -+ check_hostent ("gethostbyname (\"qam.inet6.example\")", -+ gethostbyname ("qam.inet6.example"), -+ "name: qam.inet6.example\n" - "address: 2001:db8::1\n"); -- check_hostent ("gethostbyname (\"both.example\")", -- gethostbyname ("both.example"), -- "name: both.example\n" -+ check_hostent ("gethostbyname (\"q.inet6.example\")", -+ gethostbyname ("q.inet6.example"), -+ "name: q.inet6.example\n" - "address: 2001:db8::1\n"); -- test_get2 (); -+ check_hostent ("gethostbyname (\"qm.inet6.example\")", -+ gethostbyname ("qm.inet6.example"), -+ "name: qm.inet6.example\n" -+ "address: 2001:db8::1\n"); -+ test_get2_inet6 (); -+ test_get2_inet6 (); - test_gai (); -+ test_get2_inet6 (); -+ test_get2_inet6 (); -+ -+ TEST_VERIFY (_res.options & RES_USE_INET6); -+ _res.options &= ~RES_USE_INET6; -+ test_no_inet6 (); - - resolv_test_end (obj); - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-29.patch b/srcpkgs/glibc/patches/glibc-upstream-29.patch deleted file mode 100644 index 96dc5d350d..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-29.patch +++ /dev/null @@ -1,316 +0,0 @@ -From 3005466abe8fb80ad4ff51865f1e28dd81c43347 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 6 Sep 2017 15:11:44 +0200 -Subject: [PATCH 29] nss_dns: Remove dead PTR IPv4-to-IPv6 mapping code - -(cherry picked from commit c77eb96925b719001237ca7c9e3cef40d795d66b) ---- - ChangeLog | 12 +++ - resolv/nss_dns/dns-host.c | 13 ---- - resolv/tst-res_use_inet6.c | 181 +++++++++++++++++++++++++++++++++++++++++++-- - 3 files changed, 186 insertions(+), 20 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index dd71f6c427..fa215c2729 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,17 @@ - 2017-09-06 Florian Weimer - -+ Remove dead PTR IPv4-to-IPv6 mapping code from nss_dns. -+ * resolv/nss_dns/dns-host.c (getanswer_r): Remove dead code. -+ * resolv/tst-res_use_inet6.c (response_ptr_v4, response_ptr_v6): -+ New functions. -+ (response): Call them. Add 'p', '6' flag processing. -+ (test_reverse): New function. -+ (test_get2_any): Call it. -+ (test_no_inet6): Add 'p' test. -+ (test_inet6): Likewise. -+ -+2017-09-06 Florian Weimer -+ - Enhance tst-res_use_inet6 to test IPv4-to-IPv6 address mapping. - * resolv/tst-res_use_inet6.c (response): Process flags embedded in - the QNAME. -diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c -index 7cd54ab504..1e85e4f08f 100644 ---- a/resolv/nss_dns/dns-host.c -+++ b/resolv/nss_dns/dns-host.c -@@ -889,19 +889,6 @@ getanswer_r (struct resolv_context *ctx, - /* bind would put multiple PTR records as aliases, but we don't do - that. */ - result->h_name = bp; -- if (have_to_map) -- { -- n = strlen (bp) + 1; /* for the \0 */ -- if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) -- { -- ++had_error; -- break; -- } -- bp += n; -- linebuflen -= n; -- if (map_v4v6_hostent (result, &bp, &linebuflen)) -- goto too_small; -- } - *h_errnop = NETDB_SUCCESS; - return NSS_STATUS_SUCCESS; - case T_A: -diff --git a/resolv/tst-res_use_inet6.c b/resolv/tst-res_use_inet6.c -index 1522d5c5f5..d819f921d6 100644 ---- a/resolv/tst-res_use_inet6.c -+++ b/resolv/tst-res_use_inet6.c -@@ -16,31 +16,101 @@ - License along with the GNU C Library; if not, see - . */ - -+#include - #include - #include -+#include -+#include - #include - #include - #include - #include -+#include - #include - -+/* Handle IPv4 reverse lookup responses. Product a PTR record -+ A-B-C-D.v4.example. */ -+static void -+response_ptr_v4 (const struct resolv_response_context *ctx, -+ struct resolv_response_builder *b, -+ const char *qname, uint16_t qclass, uint16_t qtype) -+{ -+ int bytes[4]; -+ int offset = -1; -+ TEST_VERIFY (sscanf (qname, "%d.%d.%d.%d.in-addr.arpa%n", -+ bytes + 0, bytes + 1, bytes + 2, bytes + 3, -+ &offset) == 4); -+ TEST_VERIFY (offset == strlen (qname)); -+ resolv_response_init (b, (struct resolv_response_flags) {}); -+ resolv_response_add_question (b, qname, qclass, qtype); -+ resolv_response_section (b, ns_s_an); -+ resolv_response_open_record (b, qname, qclass, T_PTR, 0); -+ char *name = xasprintf ("%d-%d-%d-%d.v4.example", -+ bytes[3], bytes[2], bytes[1], bytes[0]); -+ resolv_response_add_name (b, name); -+ free (name); -+ resolv_response_close_record (b); -+} -+ -+/* Handle IPv6 reverse lookup responses. Produce a PTR record -+ <32 hex digits>.v6.example. */ -+static void -+response_ptr_v6 (const struct resolv_response_context *ctx, -+ struct resolv_response_builder *b, -+ const char *qname, uint16_t qclass, uint16_t qtype) -+{ -+ -+ TEST_VERIFY_EXIT (strlen (qname) > 64); -+ -+ char bytes[33]; -+ for (int i = 0; i < 64; ++i) -+ if ((i % 2) == 0) -+ { -+ TEST_VERIFY (isxdigit ((unsigned char) qname[i])); -+ bytes[31 - i / 2] = qname[i]; -+ } -+ else -+ TEST_VERIFY_EXIT (qname[i] == '.'); -+ bytes[32] = '\0'; -+ -+ resolv_response_init (b, (struct resolv_response_flags) {}); -+ resolv_response_add_question (b, qname, qclass, qtype); -+ resolv_response_section (b, ns_s_an); -+ resolv_response_open_record (b, qname, qclass, T_PTR, 0); -+ char *name = xasprintf ("%s.v6.example", bytes); -+ resolv_response_add_name (b, name); -+ free (name); -+ resolv_response_close_record (b); -+} -+ - /* Produce a response based on QNAME: Certain characters in the first - label of QNAME trigger the inclusion of resource records: - - 'a' A record (IPv4 address) - 'q' AAAA record (quad A record, IPv6 address) -+ 'p' PTR record - 'm' record type must match QTYPE (no additional records) -+ '6' stop flag processing if QTYPE == AAAA -+ -+ For 'a' and 'q', QTYPE is ignored for record type selection if 'm' -+ is not specified. - -- QTYPE is ignored for record type selection if 'm' is not -- specified. */ -+ in-addr.arpa and ip6.arpa queries are handled separately in -+ response_ptr_v4 and response_ptr_v6. */ - static void - response (const struct resolv_response_context *ctx, - struct resolv_response_builder *b, - const char *qname, uint16_t qclass, uint16_t qtype) - { -+ if (strstr (qname, ".in-addr.arpa") != NULL) -+ return response_ptr_v4 (ctx, b, qname, qclass, qtype); -+ else if (strstr (qname, ".ip6.arpa") != NULL) -+ return response_ptr_v6 (ctx, b, qname, qclass, qtype); -+ - bool include_a = false; - bool include_aaaa = false; - bool include_match = false; -+ bool include_ptr = false; - for (const char *p = qname; *p != '.' && *p != '\0'; ++p) - { - if (*p == 'a') -@@ -49,6 +119,10 @@ response (const struct resolv_response_context *ctx, - include_aaaa = true; - else if (*p == 'm') - include_match = true; -+ else if (*p == 'p') -+ include_ptr = true; -+ else if (*p == '6' && qtype == T_AAAA) -+ break; - } - if (include_match) - { -@@ -70,11 +144,17 @@ response (const struct resolv_response_context *ctx, - } - if (include_aaaa) - { -- char ipv6[16] -- = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; -- resolv_response_open_record (b, qname, qclass, T_AAAA, 0); -- resolv_response_add_data (b, &ipv6, sizeof (ipv6)); -- resolv_response_close_record (b); -+ char ipv6[16] -+ = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; -+ resolv_response_open_record (b, qname, qclass, T_AAAA, 0); -+ resolv_response_add_data (b, &ipv6, sizeof (ipv6)); -+ resolv_response_close_record (b); -+ } -+ if (include_ptr) -+ { -+ resolv_response_open_record (b, qname, qclass, T_PTR, 0); -+ resolv_response_add_name (b, "ptr-target.example"); -+ resolv_response_close_record (b); - } - } - -@@ -162,6 +242,65 @@ test_gai (void) - } - } - -+/* Test gethostbyaddr and getnameinfo. The results are independent of -+ RES_USE_INET6. */ -+static void -+test_reverse (void) -+{ -+ { -+ char ipv4[4] = { 192, 0, 2, 17 }; -+ check_hostent ("gethostbyaddr AF_INET", -+ gethostbyaddr (ipv4, sizeof (ipv4), AF_INET), -+ "name: 192-0-2-17.v4.example\n" -+ "address: 192.0.2.17\n"); -+ } -+ { -+ char ipv6[16] -+ = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; -+ check_hostent ("gethostbyaddr AF_INET", -+ gethostbyaddr (ipv6, sizeof (ipv6), AF_INET6), -+ "name: 20010db8000000000000000000000001.v6.example\n" -+ "address: 2001:db8::1\n"); -+ } -+ -+ { -+ struct sockaddr_in addr = -+ { -+ .sin_family = AF_INET, -+ .sin_addr = { .s_addr = htonl (0xc0000211) }, -+ .sin_port = htons (80) -+ }; -+ char host[NI_MAXHOST]; -+ char service[NI_MAXSERV]; -+ int ret = getnameinfo ((struct sockaddr *) &addr, sizeof (addr), -+ host, sizeof (host), service, sizeof (service), -+ NI_NUMERICSERV); -+ TEST_VERIFY (ret == 0); -+ TEST_VERIFY (strcmp (host, "192-0-2-17.v4.example") == 0); -+ TEST_VERIFY (strcmp (service, "80") == 0); -+ } -+ { -+ char ipv6[16] -+ = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; -+ struct sockaddr_in6 addr = -+ { -+ .sin6_family = AF_INET6, -+ .sin6_port = htons (80), -+ }; -+ TEST_VERIFY (sizeof (ipv6) == sizeof (addr.sin6_addr)); -+ memcpy (&addr.sin6_addr, ipv6, sizeof (addr.sin6_addr)); -+ char host[NI_MAXHOST]; -+ char service[NI_MAXSERV]; -+ int ret = getnameinfo ((struct sockaddr *) &addr, sizeof (addr), -+ host, sizeof (host), service, sizeof (service), -+ NI_NUMERICSERV); -+ TEST_VERIFY (ret == 0); -+ TEST_VERIFY -+ (strcmp (host, "20010db8000000000000000000000001.v6.example") == 0); -+ TEST_VERIFY (strcmp (service, "80") == 0); -+ } -+} -+ - /* Test that gethostbyname2 is mostly not influenced by - RES_USE_INET6. */ - static void -@@ -207,6 +346,8 @@ test_get2_any (void) - "name: qa.example\n" - "address: 2001:db8::1\n"); - /* Additional AF_INET6 tests depend on RES_USE_INET6; see below. */ -+ -+ test_reverse (); - } - - /* gethostbyname2 tests with RES_USE_INET6 disabled. */ -@@ -254,6 +395,10 @@ test_no_inet6 (void) - gethostbyname ("am.example"), - "name: am.example\n" - "address: 192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"amp.example\")", -+ gethostbyname ("amp.example"), -+ "name: amp.example\n" -+ "address: 192.0.2.17\n"); - check_hostent ("gethostbyname (\"qam.example\")", - gethostbyname ("qam.example"), - "name: qam.example\n" -@@ -307,6 +452,28 @@ threadfunc (void *ignored) - gethostbyname ("qm.inet6.example"), - "name: qm.inet6.example\n" - "address: 2001:db8::1\n"); -+ check_hostent ("gethostbyname (\"amp.inet6.example\")", -+ gethostbyname ("amp.inet6.example"), -+ "error: NO_RECOVERY\n"); -+ check_hostent ("gethostbyname (\"qmp.inet6.example\")", -+ gethostbyname ("qmp.inet6.example"), -+ "name: qmp.inet6.example\n" -+ "address: 2001:db8::1\n"); -+ check_hostent ("gethostbyname (\"ap.inet6.example\")", -+ gethostbyname ("ap.inet6.example"), -+ "error: NO_RECOVERY\n"); -+ check_hostent ("gethostbyname (\"6ap.inet6.example\")", -+ gethostbyname ("6ap.inet6.example"), -+ "name: 6ap.inet6.example\n" -+ "address: ::ffff:192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"am6p.inet6.example\")", -+ gethostbyname ("am6p.inet6.example"), -+ "name: am6p.inet6.example\n" -+ "address: ::ffff:192.0.2.17\n"); -+ check_hostent ("gethostbyname (\"qp.inet6.example\")", -+ gethostbyname ("qp.inet6.example"), -+ "name: qp.inet6.example\n" -+ "address: 2001:db8::1\n"); - test_get2_inet6 (); - test_get2_inet6 (); - test_gai (); - diff --git a/srcpkgs/glibc/patches/glibc-upstream-30.patch b/srcpkgs/glibc/patches/glibc-upstream-30.patch deleted file mode 100644 index 6fccbe6079..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-30.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 905a6129147e7ee80e8918e23efe212433b8cce7 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 6 Sep 2017 15:46:54 +0200 -Subject: [PATCH 30] resolv: Fix memory leak with OOM during resolv.conf - parsing [BZ #22095] - -(cherry picked from commit 5670c4ab256114e869b1df4b05653aa5f909182c) ---- - ChangeLog | 6 ++++++ - NEWS | 1 + - resolv/res_init.c | 5 +++++ - 3 files changed, 12 insertions(+) - -diff --git a/ChangeLog b/ChangeLog -index fa215c2729..ef2041b9e5 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,11 @@ - 2017-09-06 Florian Weimer - -+ [BZ #22095] -+ * resolv/res_init.c (res_vinit_1): Avoid memory leak in case of -+ dynarray allocation failure. -+ -+2017-09-06 Florian Weimer -+ - Remove dead PTR IPv4-to-IPv6 mapping code from nss_dns. - * resolv/nss_dns/dns-host.c (getanswer_r): Remove dead code. - * resolv/tst-res_use_inet6.c (response_ptr_v4, response_ptr_v6): -diff --git a/NEWS b/NEWS -index 8fbf4241d1..62959274b3 100644 ---- a/NEWS -+++ b/NEWS -@@ -28,6 +28,7 @@ The following bugs are resolved with this release: - [21932] Unpaired __resolv_context_get in generic get*_r implementation - [21941] powerpc: Restrict xssqrtqp operands to Vector Registers - [21972] assert macro requires operator== (int) for its argument type -+ [22095] resolv: Fix memory leak with OOM during resolv.conf parsing - - Version 2.26 - -diff --git a/resolv/res_init.c b/resolv/res_init.c -index fa46ce7813..4e1f9fe8de 100644 ---- a/resolv/res_init.c -+++ b/resolv/res_init.c -@@ -446,6 +446,11 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser) - (&parser->nameserver_list); - if (p != NULL) - *p = sa; -+ else -+ { -+ free (sa); -+ return false; -+ } - } - continue; - } - diff --git a/srcpkgs/glibc/patches/glibc-upstream-31.patch b/srcpkgs/glibc/patches/glibc-upstream-31.patch deleted file mode 100644 index e8a6041e79..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-31.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 27233446a62ca35ce0b54566279a99a6774d4210 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 6 Sep 2017 15:47:27 +0200 -Subject: [PATCH 31] resolv: __resolv_conf_attach must not free passed conf - object [BZ #22096] - -(cherry picked from commit a83047308196e3e54716a39dd85c0a08b198d6bd) ---- - ChangeLog | 6 ++++++ - NEWS | 1 + - resolv/resolv_conf.c | 5 +---- - 3 files changed, 8 insertions(+), 4 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index ef2041b9e5..e98a4bbf3c 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,11 @@ - 2017-09-06 Florian Weimer - -+ [BZ #22096] -+ * resolv/resolv_conf.c (__resolv_conf_attach): Do not free conf in -+ case of failure to obtain the global conf object. -+ -+2017-09-06 Florian Weimer -+ - [BZ #22095] - * resolv/res_init.c (res_vinit_1): Avoid memory leak in case of - dynarray allocation failure. -diff --git a/NEWS b/NEWS -index 62959274b3..9bcb176171 100644 ---- a/NEWS -+++ b/NEWS -@@ -29,6 +29,7 @@ The following bugs are resolved with this release: - [21941] powerpc: Restrict xssqrtqp operands to Vector Registers - [21972] assert macro requires operator== (int) for its argument type - [22095] resolv: Fix memory leak with OOM during resolv.conf parsing -+ [22096] resolv: __resolv_conf_attach must not free passed conf object - - Version 2.26 - -diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c -index f391d30c27..e0f296d02e 100644 ---- a/resolv/resolv_conf.c -+++ b/resolv/resolv_conf.c -@@ -600,10 +600,7 @@ __resolv_conf_attach (struct __res_state *resp, struct resolv_conf *conf) - - struct resolv_conf_global *global_copy = get_locked_global (); - if (global_copy == NULL) -- { -- free (conf); -- return false; -- } -+ return false; - - /* Try to find an unused index in the array. */ - size_t index; - diff --git a/srcpkgs/glibc/patches/glibc-upstream-32.patch b/srcpkgs/glibc/patches/glibc-upstream-32.patch deleted file mode 100644 index 7d9e71bf6d..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-32.patch +++ /dev/null @@ -1,41 +0,0 @@ -From d265b6129184dd94da600187b67cef9125bc58c7 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 6 Sep 2017 11:25:14 +0200 -Subject: [PATCH 32] __libc_dynarray_emplace_enlarge: Add missing else - -Before, arrays of small elements received a starting allocation size of -8, not 16. ---- - ChangeLog | 5 +++++ - malloc/dynarray_emplace_enlarge.c | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index e98a4bbf3c..f82fd1f97d 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,10 @@ - 2017-09-06 Florian Weimer - -+ * malloc/dynarray_emplace_enlarge.c -+ (__libc_dynarray_emplace_enlarge): Add missing else. -+ -+2017-09-06 Florian Weimer -+ - [BZ #22096] - * resolv/resolv_conf.c (__resolv_conf_attach): Do not free conf in - case of failure to obtain the global conf object. -diff --git a/malloc/dynarray_emplace_enlarge.c b/malloc/dynarray_emplace_enlarge.c -index dfc70017ce..09cd09268b 100644 ---- a/malloc/dynarray_emplace_enlarge.c -+++ b/malloc/dynarray_emplace_enlarge.c -@@ -32,7 +32,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list, - size. */ - if (element_size < 4) - new_allocated = 16; -- if (element_size < 8) -+ else if (element_size < 8) - new_allocated = 8; - else - new_allocated = 4; - diff --git a/srcpkgs/glibc/patches/glibc-upstream-33.patch b/srcpkgs/glibc/patches/glibc-upstream-33.patch deleted file mode 100644 index 04af4e54f4..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-33.patch +++ /dev/null @@ -1,139 +0,0 @@ -From 8a1adb593969e099604537804f594efe01e04f6f Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Wed, 30 Aug 2017 20:10:56 +0200 -Subject: [PATCH 33] dynarray: Set errno on overflow-induced allocation - failure - -This allows the caller to return directly on such an error, with an -appropriate errno value. - -(cherry picked from commit 5898f4548efdcd7c0fd437a74eeb80facc51a117) ---- - ChangeLog | 8 ++++++++ - malloc/dynarray_emplace_enlarge.c | 8 ++++++-- - malloc/dynarray_resize.c | 7 ++++++- - malloc/tst-dynarray.c | 29 +++++++++++++++++++++++++++++ - 4 files changed, 49 insertions(+), 3 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index f82fd1f97d..87cc2f4865 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,11 @@ -+2017-08-30 Florian Weimer -+ -+ * malloc/dynarray_emplace_enlarge.c -+ (__libc_dynarray_emplace_enlarge): Set errno on overflow. -+ * malloc/dynarray_resize.c (__libc_dynarray_resize): Likewise. -+ * malloc/tst-dynarray.c (test_long_overflow): New function. -+ (do_test): Call it. -+ - 2017-09-06 Florian Weimer - - * malloc/dynarray_emplace_enlarge.c -diff --git a/malloc/dynarray_emplace_enlarge.c b/malloc/dynarray_emplace_enlarge.c -index 09cd09268b..a15245f4cb 100644 ---- a/malloc/dynarray_emplace_enlarge.c -+++ b/malloc/dynarray_emplace_enlarge.c -@@ -17,6 +17,7 @@ - . */ - - #include -+#include - #include - #include - #include -@@ -43,8 +44,11 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list, - { - new_allocated = list->allocated + list->allocated / 2 + 1; - if (new_allocated <= list->allocated) -- /* Overflow. */ -- return false; -+ { -+ /* Overflow. */ -+ __set_errno (ENOMEM); -+ return false; -+ } - } - - size_t new_size; -diff --git a/malloc/dynarray_resize.c b/malloc/dynarray_resize.c -index e6dc9fbc68..63c981bf61 100644 ---- a/malloc/dynarray_resize.c -+++ b/malloc/dynarray_resize.c -@@ -17,6 +17,7 @@ - . */ - - #include -+#include - #include - #include - #include -@@ -38,7 +39,11 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size, - - size_t new_size_bytes; - if (check_mul_overflow_size_t (size, element_size, &new_size_bytes)) -- return false; -+ { -+ /* Overflow. */ -+ __set_errno (ENOMEM); -+ return false; -+ } - void *new_array; - if (list->array == scratch) - { -diff --git a/malloc/tst-dynarray.c b/malloc/tst-dynarray.c -index 2206d75e31..d11f7bb8a3 100644 ---- a/malloc/tst-dynarray.c -+++ b/malloc/tst-dynarray.c -@@ -18,6 +18,9 @@ - - #include "tst-dynarray-shared.h" - -+#include -+#include -+ - #define DYNARRAY_STRUCT dynarray_long - #define DYNARRAY_ELEMENT long - #define DYNARRAY_PREFIX dynarray_long_ -@@ -463,6 +466,31 @@ test_long_init (void) - } - } - -+/* Test overflow in resize. */ -+static void -+test_long_overflow (void) -+{ -+ { -+ struct dynarray_long dyn; -+ dynarray_long_init (&dyn); -+ errno = EINVAL; -+ TEST_VERIFY (!dynarray_long_resize -+ (&dyn, (SIZE_MAX / sizeof (long)) + 1)); -+ TEST_VERIFY (errno == ENOMEM); -+ TEST_VERIFY (dynarray_long_has_failed (&dyn)); -+ } -+ -+ { -+ struct dynarray_long_noscratch dyn; -+ dynarray_long_noscratch_init (&dyn); -+ errno = EINVAL; -+ TEST_VERIFY (!dynarray_long_noscratch_resize -+ (&dyn, (SIZE_MAX / sizeof (long)) + 1)); -+ TEST_VERIFY (errno == ENOMEM); -+ TEST_VERIFY (dynarray_long_noscratch_has_failed (&dyn)); -+ } -+} -+ - /* Test NUL-terminated string construction with the add function and - the simple finalize function. */ - static void -@@ -538,6 +566,7 @@ do_test (void) - test_int (); - test_str (); - test_long_init (); -+ test_long_overflow (); - test_zstr (); - return 0; - } - diff --git a/srcpkgs/glibc/patches/glibc-upstream-34.patch b/srcpkgs/glibc/patches/glibc-upstream-34.patch deleted file mode 100644 index fa8bd627aa..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-34.patch +++ /dev/null @@ -1,59 +0,0 @@ -From dca8b177f6bb521638f4d8a845b4cb10348137c9 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Thu, 31 Aug 2017 06:28:31 -0700 -Subject: [PATCH 34] Place $(elf-objpfx)sofini.os last [BZ #22051] - -Since sofini.os terminates .eh_frame section, it should be placed last. - - [BZ #22051] - * Makerules (build-module-helper-objlist): Filter out - $(elf-objpfx)sofini.os. - (build-shlib-objlist): Append $(elf-objpfx)sofini.os if it is - needed. - -(cherry picked from commit ecd0747df388f3925d4839740b0abcf43d0a9fb2) ---- - ChangeLog | 8 ++++++++ - Makerules | 5 ++++- - 2 files changed, 12 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 87cc2f4865..f9e423dbb3 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,11 @@ -+2017-08-31 H.J. Lu -+ -+ [BZ #22051] -+ * Makerules (build-module-helper-objlist): Filter out -+ $(elf-objpfx)sofini.os. -+ (build-shlib-objlist): Append $(elf-objpfx)sofini.os if it is -+ needed. -+ - 2017-08-30 Florian Weimer - - * malloc/dynarray_emplace_enlarge.c -diff --git a/Makerules b/Makerules -index 9bb707c168..828a445f24 100644 ---- a/Makerules -+++ b/Makerules -@@ -686,14 +686,17 @@ $(build-module-helper) -o $@ $(shlib-lds-flags) \ - $(call after-link,$@) - endef - -+# sofini.os must be placed last since it terminates .eh_frame section. - build-module-helper-objlist = \ - $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\ - $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \ -+ $(elf-objpfx)sofini.os \ - $(link-libc-deps),$^)) - - build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so) - build-shlib-objlist = $(build-module-helper-objlist) \ -- $(LDLIBS-$(@F:lib%.so=%).so) -+ $(LDLIBS-$(@F:lib%.so=%).so) \ -+ $(filter $(elf-objpfx)sofini.os,$^) - - # Don't try to use -lc when making libc.so itself. - # Also omits crti.o and crtn.o, which we do not want - diff --git a/srcpkgs/glibc/patches/glibc-upstream-35.patch b/srcpkgs/glibc/patches/glibc-upstream-35.patch deleted file mode 100644 index 2709a43be8..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-35.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 86553be84d071aee8464b2c2fa03858d12118852 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Thu, 7 Sep 2017 13:56:58 -0700 -Subject: [PATCH 35] Use "static const char domain[] =" - - * resolv/tst-resolv-qtypes.c (domain): Changed to - "const char domain[] =". - -(cherry picked from commit 78bfa877b36e8f33c99cbe9a16eb73f5a2adc0c8) ---- - ChangeLog | 5 +++++ - resolv/tst-resolv-qtypes.c | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index f9e423dbb3..96c461c441 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,8 @@ -+2017-09-07 H.J. Lu -+ -+ * resolv/tst-resolv-qtypes.c (domain): Changed to -+ "const char domain[] =". -+ - 2017-08-31 H.J. Lu - - [BZ #22051] -diff --git a/resolv/tst-resolv-qtypes.c b/resolv/tst-resolv-qtypes.c -index 06ea3dbd14..da3325f80c 100644 ---- a/resolv/tst-resolv-qtypes.c -+++ b/resolv/tst-resolv-qtypes.c -@@ -50,7 +50,7 @@ response (const struct resolv_response_context *ctx, - resolv_response_close_record (b); - } - --static const char * const domain = "www.example.com"; -+static const char domain[] = "www.example.com"; - - static int - wrap_res_query (int type, unsigned char *answer, int answer_length) - diff --git a/srcpkgs/glibc/patches/glibc-upstream-36.patch b/srcpkgs/glibc/patches/glibc-upstream-36.patch deleted file mode 100644 index 675a9c9818..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-36.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 5f5532caf820f47f714d09766082f1e070c12cfb Mon Sep 17 00:00:00 2001 -From: Markus Trippelsdorf -Date: Fri, 8 Sep 2017 19:57:12 +0000 -Subject: [PATCH 36] Update x86_64 ulps for AMD Ryzen. - - * sysdeps/x86_64/fpu/libm-test-ulps: Update for AMD Ryzen. - -(cherry picked from commit 4c03a696800e3bb4b433626a65c4fef465dcc98b) ---- - ChangeLog | 4 ++++ - sysdeps/x86_64/fpu/libm-test-ulps | 4 ++-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 96c461c441..c180f8dbca 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,7 @@ -+2017-09-08 Markus Trippelsdorf -+ -+ * sysdeps/x86_64/fpu/libm-test-ulps: Update for AMD Ryzen. -+ - 2017-09-07 H.J. Lu - - * resolv/tst-resolv-qtypes.c (domain): Changed to -diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps -index c347642044..1e28aaa9f1 100644 ---- a/sysdeps/x86_64/fpu/libm-test-ulps -+++ b/sysdeps/x86_64/fpu/libm-test-ulps -@@ -1733,10 +1733,10 @@ ldouble: 3 - - Function: Imaginary part of "ctan_upward": - double: 2 --float: 1 -+float: 2 - float128: 5 - idouble: 2 --ifloat: 1 -+ifloat: 2 - ifloat128: 5 - ildouble: 3 - ldouble: 3 - diff --git a/srcpkgs/glibc/patches/glibc-upstream-37.patch b/srcpkgs/glibc/patches/glibc-upstream-37.patch deleted file mode 100644 index 55c7b7ac63..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-37.patch +++ /dev/null @@ -1,654 +0,0 @@ -From 56ce01906ecb0a3e04411f8ceb60b27f4877f070 Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Wed, 23 Aug 2017 08:22:52 -0700 -Subject: [PATCH 37] string/stratcliff.c: Replace int with size_t [BZ - #21982] -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Fix GCC 7 errors when string/stratcliff.c is compiled with -O3: - -stratcliff.c: In function ‘do_test’: -cc1: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow] - - [BZ #21982] - * string/stratcliff.c (do_test): Declare size, nchars, inner, - middle and outer with size_t instead of int. Repleace %d and - %Zd with %zu in printf. Update "MAX (0, nchars - 128)" and - "MAX (outer, nchars - 64)" to support unsigned outer and - nchars. Also exit loop when outer == 0. - -(cherry picked from commit 376b40a27a6783ea7f73ae577be320df66aeb36d) ---- - ChangeLog | 9 ++ - string/stratcliff.c | 276 +++++++++++++++++++++++++++++++--------------------- - 2 files changed, 176 insertions(+), 109 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index c180f8dbca..84721f6265 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,12 @@ -+2017-09-11 H.J. Lu -+ -+ [BZ #21982] -+ * string/stratcliff.c (do_test): Declare size, nchars, inner, -+ middle and outer with size_t instead of int. Repleace %d and -+ %Zd with %zu in printf. Update "MAX (0, nchars - 128)" and -+ "MAX (outer, nchars - 64)" to support unsigned outer and -+ nchars. Also exit loop when outer == 0. -+ - 2017-09-08 Markus Trippelsdorf - - * sysdeps/x86_64/fpu/libm-test-ulps: Update for AMD Ryzen. -diff --git a/string/stratcliff.c b/string/stratcliff.c -index e28b0c5058..4320336c9a 100644 ---- a/string/stratcliff.c -+++ b/string/stratcliff.c -@@ -58,8 +58,8 @@ - int - do_test (void) - { -- int size = sysconf (_SC_PAGESIZE); -- int nchars = size / sizeof (CHAR); -+ size_t size = sysconf (_SC_PAGESIZE); -+ size_t nchars = size / sizeof (CHAR); - CHAR *adr; - CHAR *dest; - int result = 0; -@@ -80,7 +80,17 @@ do_test (void) - } - else - { -- int inner, middle, outer; -+ size_t inner, middle, outer, nchars64, max128; -+ -+ if (nchars > 64) -+ nchars64 = nchars - 64; -+ else -+ nchars64 = 0; -+ -+ if (nchars > 128) -+ max128 = nchars - 128; -+ else -+ max128 = 0; - - mprotect (adr, size, PROT_NONE); - mprotect (adr + 2 * nchars, size, PROT_NONE); -@@ -93,59 +103,65 @@ do_test (void) - MEMSET (adr, L('T'), nchars); - - /* strlen/wcslen test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner < nchars; ++inner) - { - adr[inner] = L('\0'); - - if (STRLEN (&adr[outer]) != (size_t) (inner - outer)) - { -- printf ("%s flunked for outer = %d, inner = %d\n", -+ printf ("%s flunked for outer = %zu, inner = %zu\n", - STRINGIFY (STRLEN), outer, inner); - result = 1; - } - - adr[inner] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* strnlen/wcsnlen test */ -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner < nchars; ++inner) - { - adr[inner] = L('\0'); - - if (STRNLEN (&adr[outer], inner - outer + 1) - != (size_t) (inner - outer)) - { -- printf ("%s flunked for outer = %d, inner = %d\n", -+ printf ("%s flunked for outer = %zu, inner = %zu\n", - STRINGIFY (STRNLEN), outer, inner); - result = 1; - } - - adr[inner] = L('T'); - } -+ if (outer == 0) -+ break; - } -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner <= nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner <= nchars; ++inner) - { - if (STRNLEN (&adr[outer], inner - outer) - != (size_t) (inner - outer)) - { -- printf ("%s flunked bounded for outer = %d, inner = %d\n", -+ printf ("%s flunked bounded for outer = %zu, inner = %zu\n", - STRINGIFY (STRNLEN), outer, inner); - result = 1; - } - } -+ if (outer == 0) -+ break; - } - - /* strchr/wcschr test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - for (inner = middle; inner < nchars; ++inner) - { -@@ -158,8 +174,8 @@ do_test (void) - || (inner != middle - && (cp - &adr[outer]) != middle - outer)) - { -- printf ("%s flunked for outer = %d, middle = %d, " -- "inner = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu, " -+ "inner = %zu\n", - STRINGIFY (STRCHR), outer, middle, inner); - result = 1; - } -@@ -168,6 +184,8 @@ do_test (void) - adr[middle] = L('T'); - } - } -+ if (outer == 0) -+ break; - } - - /* Special test. */ -@@ -180,9 +198,9 @@ do_test (void) - } - - /* strrchr/wcsrchr test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - for (inner = middle; inner < nchars; ++inner) - { -@@ -195,8 +213,8 @@ do_test (void) - || (inner != middle - && (cp - &adr[outer]) != middle - outer)) - { -- printf ("%s flunked for outer = %d, middle = %d, " -- "inner = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu, " -+ "inner = %zu\n", - STRINGIFY (STRRCHR), outer, middle, inner); - result = 1; - } -@@ -205,12 +223,14 @@ do_test (void) - adr[middle] = L('T'); - } - } -+ if (outer == 0) -+ break; - } - - /* memchr test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - adr[middle] = L('V'); - -@@ -218,32 +238,36 @@ do_test (void) - - if (cp - &adr[outer] != middle - outer) - { -- printf ("%s flunked for outer = %d, middle = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu\n", - STRINGIFY (MEMCHR), outer, middle); - result = 1; - } - - adr[middle] = L('T'); - } -+ if (outer == 0) -+ break; - } -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { - CHAR *cp = MEMCHR (&adr[outer], L('V'), nchars - outer); - - if (cp != NULL) - { -- printf ("%s flunked for outer = %d\n", -+ printf ("%s flunked for outer = %zu\n", - STRINGIFY (MEMCHR), outer); - result = 1; - } -+ if (outer == 0) -+ break; - } - - /* These functions only exist for single-byte characters. */ - #ifndef WCSTEST - /* rawmemchr test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - adr[middle] = L('V'); - -@@ -251,19 +275,21 @@ do_test (void) - - if (cp - &adr[outer] != middle - outer) - { -- printf ("%s flunked for outer = %d, middle = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu\n", - STRINGIFY (rawmemchr), outer, middle); - result = 1; - } - - adr[middle] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* memrchr test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - adr[middle] = L('V'); - -@@ -271,44 +297,50 @@ do_test (void) - - if (cp - &adr[outer] != middle - outer) - { -- printf ("%s flunked for outer = %d, middle = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu\n", - STRINGIFY (memrchr), outer, middle); - result = 1; - } - - adr[middle] = L('T'); - } -+ if (outer == 0) -+ break; - } -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { - CHAR *cp = memrchr (&adr[outer], L('V'), nchars - outer); - - if (cp != NULL) - { -- printf ("%s flunked for outer = %d\n", -+ printf ("%s flunked for outer = %zu\n", - STRINGIFY (memrchr), outer); - result = 1; - } -+ if (outer == 0) -+ break; - } - #endif - - /* strcpy/wcscpy test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner < nchars; ++inner) - { - adr[inner] = L('\0'); - - if (STRCPY (dest, &adr[outer]) != dest - || STRLEN (dest) != (size_t) (inner - outer)) - { -- printf ("%s flunked for outer = %d, inner = %d\n", -+ printf ("%s flunked for outer = %zu, inner = %zu\n", - STRINGIFY (STRCPY), outer, inner); - result = 1; - } - - adr[inner] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* strcmp/wcscmp tests */ -@@ -322,14 +354,14 @@ do_test (void) - - if (STRCMP (adr + middle, dest + nchars - outer) <= 0) - { -- printf ("%s 1 flunked for outer = %d, middle = %d\n", -+ printf ("%s 1 flunked for outer = %zu, middle = %zu\n", - STRINGIFY (STRCMP), outer, middle); - result = 1; - } - - if (STRCMP (dest + nchars - outer, adr + middle) >= 0) - { -- printf ("%s 2 flunked for outer = %d, middle = %d\n", -+ printf ("%s 2 flunked for outer = %zu, middle = %zu\n", - STRINGIFY (STRCMP), outer, middle); - result = 1; - } -@@ -348,16 +380,16 @@ do_test (void) - { - if (STRNCMP (adr + middle, dest + nchars - outer, inner) != 0) - { -- printf ("%s 1 flunked for outer = %d, middle = %d, " -- "inner = %d\n", -+ printf ("%s 1 flunked for outer = %zu, middle = %zu, " -+ "inner = %zu\n", - STRINGIFY (STRNCMP), outer, middle, inner); - result = 1; - } - - if (STRNCMP (dest + nchars - outer, adr + middle, inner) != 0) - { -- printf ("%s 2 flunked for outer = %d, middle = %d, " -- "inner = %d\n", -+ printf ("%s 2 flunked for outer = %zu, middle = %zu, " -+ "inner = %zu\n", - STRINGIFY (STRNCMP), outer, middle, inner); - result = 1; - } -@@ -365,14 +397,14 @@ do_test (void) - - if (STRNCMP (adr + middle, dest + nchars - outer, outer) >= 0) - { -- printf ("%s 1 flunked for outer = %d, middle = %d, full\n", -+ printf ("%s 1 flunked for outer = %zu, middle = %zu, full\n", - STRINGIFY (STRNCMP), outer, middle); - result = 1; - } - - if (STRNCMP (dest + nchars - outer, adr + middle, outer) <= 0) - { -- printf ("%s 2 flunked for outer = %d, middle = %d, full\n", -+ printf ("%s 2 flunked for outer = %zu, middle = %zu, full\n", - STRINGIFY (STRNCMP), outer, middle); - result = 1; - } -@@ -380,7 +412,7 @@ do_test (void) - - /* strncpy/wcsncpy tests */ - adr[nchars - 1] = L('T'); -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { - size_t len; - -@@ -389,17 +421,19 @@ do_test (void) - if (STRNCPY (dest, &adr[outer], len) != dest - || MEMCMP (dest, &adr[outer], len) != 0) - { -- printf ("outer %s flunked for outer = %d, len = %Zd\n", -+ printf ("outer %s flunked for outer = %zu, len = %zu\n", - STRINGIFY (STRNCPY), outer, len); - result = 1; - } - } -+ if (outer == 0) -+ break; - } - adr[nchars - 1] = L('\0'); - -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner < nchars; ++inner) - { - size_t len; - -@@ -413,8 +447,8 @@ do_test (void) - || (inner - outer < len - && STRLEN (dest) != (inner - outer))) - { -- printf ("%s flunked for outer = %d, inner = %d, " -- "len = %Zd\n", -+ printf ("%s flunked for outer = %zu, inner = %zu, " -+ "len = %zu\n", - STRINGIFY (STRNCPY), outer, inner, len); - result = 1; - } -@@ -424,8 +458,8 @@ do_test (void) - || (inner - outer < len - && STRLEN (dest + 1) != (inner - outer))) - { -- printf ("%s+1 flunked for outer = %d, inner = %d, " -- "len = %Zd\n", -+ printf ("%s+1 flunked for outer = %zu, inner = %zu, " -+ "len = %zu\n", - STRINGIFY (STRNCPY), outer, inner, len); - result = 1; - } -@@ -433,29 +467,33 @@ do_test (void) - - adr[inner] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* stpcpy/wcpcpy test */ -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) -+ for (inner = MAX (outer, nchars64); inner < nchars; ++inner) - { - adr[inner] = L('\0'); - - if ((STPCPY (dest, &adr[outer]) - dest) != inner - outer) - { -- printf ("%s flunked for outer = %d, inner = %d\n", -+ printf ("%s flunked for outer = %zu, inner = %zu\n", - STRINGIFY (STPCPY), outer, inner); - result = 1; - } - - adr[inner] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* stpncpy/wcpncpy test */ - adr[nchars - 1] = L('T'); -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars; outer >= max128; --outer) - { - size_t len; - -@@ -464,17 +502,19 @@ do_test (void) - if (STPNCPY (dest, &adr[outer], len) != dest + len - || MEMCMP (dest, &adr[outer], len) != 0) - { -- printf ("outer %s flunked for outer = %d, len = %Zd\n", -+ printf ("outer %s flunked for outer = %zu, len = %zu\n", - STRINGIFY (STPNCPY), outer, len); - result = 1; - } - } -+ if (outer == 0) -+ break; - } - adr[nchars - 1] = L('\0'); - -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -+ for (outer = nchars - 1; outer >= max128; --outer) - { -- for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) -+ for (middle = MAX (outer, nchars64); middle < nchars; ++middle) - { - adr[middle] = L('\0'); - -@@ -483,8 +523,8 @@ do_test (void) - if ((STPNCPY (dest, &adr[outer], inner) - dest) - != MIN (inner, middle - outer)) - { -- printf ("%s flunked for outer = %d, middle = %d, " -- "inner = %d\n", -+ printf ("%s flunked for outer = %zu, middle = %zu, " -+ "inner = %zu\n", - STRINGIFY (STPNCPY), outer, middle, inner); - result = 1; - } -@@ -492,66 +532,84 @@ do_test (void) - - adr[middle] = L('T'); - } -+ if (outer == 0) -+ break; - } - - /* memcpy/wmemcpy test */ -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -- for (inner = 0; inner < nchars - outer; ++inner) -- if (MEMCPY (dest, &adr[outer], inner) != dest) -- { -- printf ("%s flunked for outer = %d, inner = %d\n", -- STRINGIFY (MEMCPY), outer, inner); -- result = 1; -- } -+ for (outer = nchars; outer >= max128; --outer) -+ { -+ for (inner = 0; inner < nchars - outer; ++inner) -+ if (MEMCPY (dest, &adr[outer], inner) != dest) -+ { -+ printf ("%s flunked for outer = %zu, inner = %zu\n", -+ STRINGIFY (MEMCPY), outer, inner); -+ result = 1; -+ } -+ if (outer == 0) -+ break; -+ } - - /* mempcpy/wmempcpy test */ -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -- for (inner = 0; inner < nchars - outer; ++inner) -- if (MEMPCPY (dest, &adr[outer], inner) != dest + inner) -- { -- printf ("%s flunked for outer = %d, inner = %d\n", -- STRINGIFY (MEMPCPY), outer, inner); -- result = 1; -- } -+ for (outer = nchars; outer >= max128; --outer) -+ { -+ for (inner = 0; inner < nchars - outer; ++inner) -+ if (MEMPCPY (dest, &adr[outer], inner) != dest + inner) -+ { -+ printf ("%s flunked for outer = %zu, inner = %zu\n", -+ STRINGIFY (MEMPCPY), outer, inner); -+ result = 1; -+ } -+ if (outer == 0) -+ break; -+ } - - /* This function only exists for single-byte characters. */ - #ifndef WCSTEST - /* memccpy test */ - memset (adr, '\0', nchars); -- for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) -- for (inner = 0; inner < nchars - outer; ++inner) -- if (memccpy (dest, &adr[outer], L('\1'), inner) != NULL) -- { -- printf ("memccpy flunked full copy for outer = %d, inner = %d\n", -- outer, inner); -- result = 1; -- } -- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) -- for (middle = 0; middle < nchars - outer; ++middle) -- { -- memset (dest, L('\2'), middle + 1); -- for (inner = 0; inner < middle; ++inner) -+ for (outer = nchars; outer >= max128; --outer) -+ { -+ for (inner = 0; inner < nchars - outer; ++inner) -+ if (memccpy (dest, &adr[outer], L('\1'), inner) != NULL) - { -- adr[outer + inner] = L('\1'); -- -- if (memccpy (dest, &adr[outer], '\1', middle + 128) -- != dest + inner + 1) -- { -- printf ("\ --memccpy flunked partial copy for outer = %d, middle = %d, inner = %d\n", -- outer, middle, inner); -- result = 1; -- } -- else if (dest[inner + 1] != L('\2')) -- { -- printf ("\ --memccpy copied too much for outer = %d, middle = %d, inner = %d\n", -- outer, middle, inner); -- result = 1; -- } -- adr[outer + inner] = L('\0'); -+ printf ("memccpy flunked full copy for outer = %zu, inner = %zu\n", -+ outer, inner); -+ result = 1; - } -- } -+ if (outer == 0) -+ break; -+ } -+ for (outer = nchars - 1; outer >= max128; --outer) -+ { -+ for (middle = 0; middle < nchars - outer; ++middle) -+ { -+ memset (dest, L('\2'), middle + 1); -+ for (inner = 0; inner < middle; ++inner) -+ { -+ adr[outer + inner] = L('\1'); -+ -+ if (memccpy (dest, &adr[outer], '\1', middle + 128) -+ != dest + inner + 1) -+ { -+ printf ("\ -+ memccpy flunked partial copy for outer = %zu, middle = %zu, inner = %zu\n", -+ outer, middle, inner); -+ result = 1; -+ } -+ else if (dest[inner + 1] != L('\2')) -+ { -+ printf ("\ -+ memccpy copied too much for outer = %zu, middle = %zu, inner = %zu\n", -+ outer, middle, inner); -+ result = 1; -+ } -+ adr[outer + inner] = L('\0'); -+ } -+ } -+ if (outer == 0) -+ break; -+ } - #endif - } - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-38.patch b/srcpkgs/glibc/patches/glibc-upstream-38.patch deleted file mode 100644 index 6f418d08c1..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-38.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 2422c6032fd5e95b1c29df5b8671455ead51314e Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Thu, 3 Aug 2017 15:39:21 +0930 -Subject: [PATCH 38] tst-tlsopt-powerpc as a shared lib - -This makes the __tls_get_addr_opt test run as a shared library, and so -actually test that DTPMOD64/DTPREL64 pairs are processed by ld.so to -support the __tls_get_adfr_opt call stub fast return. After a -2017-01-24 patch (binutils f0158f4416) ld.bfd no longer emitted -unnecessary dynamic relocations against local thread variables, -instead setting up the __tls_index GOT entries for the call stub fast -return. This meant tst-tlsopt-powerpc passed but did not check ld.so -relocation support. After a 2017-07-16 patch (binutils 676ee2b5fa) -ld.bfd no longer set up the __tls_index GOT entries for the call stub -fast return, and tst-tlsopt-powerpc failed. - -Compiling mod-tlsopt-powerpc.c with -DSHARED exposed a bug in -powerpc64/tls-macros.h, which defines a __TLS_GET_ADDR macro that -clashes with one defined in dl-tls.h. The tls-macros.h version is -only used in that file, so delete it and expand. - - * sysdeps/powerpc/mod-tlsopt-powerpc.c: Extract from - tst-tlsopt-powerpc.c with function name change and no test harness. - * sysdeps/powerpc/tst-tlsopt-powerpc.c: Remove body of test. - Call tls_get_addr_opt_test. - * sysdeps/powerpc/Makefile (LDFLAGS-tst-tlsopt-powerpc): Don't define. - (modules-names): Add mod-tlsopt-powerpc. - (mod-tlsopt-powerpc.so-no-z-defs): Define. - (tst-tlsopt-powerpc): Depend on .so. - * sysdeps/powerpc/powerpc64/tls-macros.h (__TLS_GET_ADDR): Don't - define. Expand use in TLS_GD and TLS_LD. - -(cherry picked from commit e98c925fa4f6486447eb20676755dbf9eb36a110) ---- - ChangeLog | 13 +++++++++ - sysdeps/powerpc/Makefile | 6 +++-- - sysdeps/powerpc/mod-tlsopt-powerpc.c | 49 ++++++++++++++++++++++++++++++++++ - sysdeps/powerpc/powerpc64/tls-macros.h | 6 ++--- - sysdeps/powerpc/tst-tlsopt-powerpc.c | 44 ++---------------------------- - 5 files changed, 70 insertions(+), 48 deletions(-) - create mode 100644 sysdeps/powerpc/mod-tlsopt-powerpc.c - -diff --git a/ChangeLog b/ChangeLog -index 84721f6265..b53d8830a2 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,16 @@ -+2017-08-03 Alan Modra -+ -+ * sysdeps/powerpc/mod-tlsopt-powerpc.c: Extract from -+ tst-tlsopt-powerpc.c with function name change and no test harness. -+ * sysdeps/powerpc/tst-tlsopt-powerpc.c: Remove body of test. -+ Call tls_get_addr_opt_test. -+ * sysdeps/powerpc/Makefile (LDFLAGS-tst-tlsopt-powerpc): Don't define. -+ (modules-names): Add mod-tlsopt-powerpc. -+ (mod-tlsopt-powerpc.so-no-z-defs): Define. -+ (tst-tlsopt-powerpc): Depend on .so. -+ * sysdeps/powerpc/powerpc64/tls-macros.h (__TLS_GET_ADDR): Don't -+ define. Expand use in TLS_GD and TLS_LD. -+ - 2017-09-11 H.J. Lu - - [BZ #21982] -diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile -index 0d9206bec4..6aa683b03f 100644 ---- a/sysdeps/powerpc/Makefile -+++ b/sysdeps/powerpc/Makefile -@@ -8,9 +8,11 @@ sysdep-dl-routines += dl-machine hwcapinfo - sysdep_routines += dl-machine hwcapinfo - # extra shared linker files to link only into dl-allobjs.so - sysdep-rtld-routines += dl-machine hwcapinfo --# Don't optimize GD tls sequence to LE. --LDFLAGS-tst-tlsopt-powerpc += -Wl,--no-tls-optimize -+ -+modules-names += mod-tlsopt-powerpc -+mod-tlsopt-powerpc.so-no-z-defs = yes - tests += tst-tlsopt-powerpc -+$(objpfx)tst-tlsopt-powerpc: $(objpfx)mod-tlsopt-powerpc.so - - ifneq (no,$(multi-arch)) - tests-static += tst-tlsifunc-static -diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c -new file mode 100644 -index 0000000000..ee0db12a73 ---- /dev/null -+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c -@@ -0,0 +1,49 @@ -+/* shared library to test for __tls_get_addr optimization. */ -+#include -+ -+#include "../../elf/tls-macros.h" -+#include "dl-tls.h" -+ -+/* common 'int' variable in TLS. */ -+COMMON_INT_DEF(foo); -+ -+ -+int -+tls_get_addr_opt_test (void) -+{ -+ int result = 0; -+ -+ /* Get variable using general dynamic model. */ -+ int *ap = TLS_GD (foo); -+ if (*ap != 0) -+ { -+ printf ("foo = %d\n", *ap); -+ result = 1; -+ } -+ -+ tls_index *tls_arg; -+#ifdef __powerpc64__ -+ register unsigned long thread_pointer __asm__ ("r13"); -+ asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg)); -+#else -+ register unsigned long thread_pointer __asm__ ("r2"); -+ asm ("bcl 20,31,1f\n1:\t" -+ "mflr %0\n\t" -+ "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" -+ "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" -+ "addi %0,%0,foo@got@tlsgd" : "=b" (tls_arg)); -+#endif -+ -+ if (tls_arg->ti_module != 0) -+ { -+ printf ("tls_index not optimized, binutils too old?\n"); -+ result = 1; -+ } -+ else if (tls_arg->ti_offset + thread_pointer != (unsigned long) ap) -+ { -+ printf ("tls_index->ti_offset wrong value\n"); -+ result = 1; -+ } -+ -+ return result; -+} -diff --git a/sysdeps/powerpc/powerpc64/tls-macros.h b/sysdeps/powerpc/powerpc64/tls-macros.h -index 42a95ec5c1..79a0b2579c 100644 ---- a/sysdeps/powerpc/powerpc64/tls-macros.h -+++ b/sysdeps/powerpc/powerpc64/tls-macros.h -@@ -18,13 +18,11 @@ - __result; \ - }) - --#define __TLS_GET_ADDR "__tls_get_addr" -- - /* PowerPC64 Local Dynamic TLS access. */ - #define TLS_LD(x) \ - ({ int * __result; \ - asm ("addi 3,2," #x "@got@tlsld\n\t" \ -- "bl " __TLS_GET_ADDR "\n\t" \ -+ "bl __tls_get_addr\n\t" \ - "nop \n\t" \ - "addis %0,3," #x "@dtprel@ha\n\t" \ - "addi %0,%0," #x "@dtprel@l" \ -@@ -36,7 +34,7 @@ - #define TLS_GD(x) \ - ({ register int *__result __asm__ ("r3"); \ - asm ("addi 3,2," #x "@got@tlsgd\n\t" \ -- "bl " __TLS_GET_ADDR "\n\t" \ -+ "bl __tls_get_addr\n\t" \ - "nop " \ - : "=r" (__result) : \ - : __TLS_CALL_CLOBBERS); \ -diff --git a/sysdeps/powerpc/tst-tlsopt-powerpc.c b/sysdeps/powerpc/tst-tlsopt-powerpc.c -index 8ae928a3f4..cc682b2ed0 100644 ---- a/sysdeps/powerpc/tst-tlsopt-powerpc.c -+++ b/sysdeps/powerpc/tst-tlsopt-powerpc.c -@@ -1,51 +1,11 @@ - /* glibc test for __tls_get_addr optimization. */ --#include -- --#include "../../elf/tls-macros.h" --#include "dl-tls.h" -- --/* common 'int' variable in TLS. */ --COMMON_INT_DEF(foo); -- - - static int - do_test (void) - { -- int result = 0; -- -- /* Get variable using general dynamic model. */ -- int *ap = TLS_GD (foo); -- if (*ap != 0) -- { -- printf ("foo = %d\n", *ap); -- result = 1; -- } -- -- tls_index *tls_arg; --#ifdef __powerpc64__ -- register unsigned long thread_pointer __asm__ ("r13"); -- asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg)); --#else -- register unsigned long thread_pointer __asm__ ("r2"); -- asm ("bcl 20,31,1f\n1:\t" -- "mflr %0\n\t" -- "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" -- "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" -- "addi %0,%0,foo@got@tlsgd" : "=b" (tls_arg)); --#endif -- -- if (tls_arg->ti_module != 0) -- { -- printf ("tls_index not optimized, binutils too old?\n"); -- result = 1; -- } -- else if (tls_arg->ti_offset + thread_pointer != (unsigned long) ap) -- { -- printf ("tls_index->ti_offset wrong value\n"); -- result = 1; -- } -+ extern int tls_get_addr_opt_test (void); - -- return result; -+ return tls_get_addr_opt_test (); - } - - #include - diff --git a/srcpkgs/glibc/patches/glibc-upstream-39.patch b/srcpkgs/glibc/patches/glibc-upstream-39.patch deleted file mode 100644 index d1cd4dd25a..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-39.patch +++ /dev/null @@ -1,41 +0,0 @@ -From ac6113cb0146494af7ecacbbdc6957ce501a40ec Mon Sep 17 00:00:00 2001 -From: Martin Sebor -Date: Tue, 22 Aug 2017 09:35:23 -0600 -Subject: [PATCH 39] Declare ifunc resolver to return a pointer to the same - type as the target function to help GCC detect incompatibilities between the - two when it's enhanced to do so. - -(cherry picked from commit ee4e992ebe5f9712faedeefe8958b67d61eaa0f2) ---- - ChangeLog | 5 +++++ - include/libc-symbols.h | 3 ++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index b53d8830a2..ec9b9f5edb 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,8 @@ -+2017-08-22 Martin Sebor -+ -+ * include/libc-symbols.h (__ifunc_resolver): Declare resolver -+ to return a pointer to the same type as the target function. -+ - 2017-08-03 Alan Modra - - * sysdeps/powerpc/mod-tlsopt-powerpc.c: Extract from -diff --git a/include/libc-symbols.h b/include/libc-symbols.h -index 3310e3a678..c50f9adec2 100644 ---- a/include/libc-symbols.h -+++ b/include/libc-symbols.h -@@ -782,7 +782,8 @@ for linking") - - /* Helper / base macros for indirect function symbols. */ - #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \ -- classifier inhibit_stack_protector void *name##_ifunc (arg) \ -+ classifier inhibit_stack_protector \ -+ __typeof (type_name) *name##_ifunc (arg) \ - { \ - init (); \ - __typeof (type_name) *res = expr; \ - diff --git a/srcpkgs/glibc/patches/glibc-upstream-40.patch b/srcpkgs/glibc/patches/glibc-upstream-40.patch deleted file mode 100644 index 4a082b4821..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-40.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 37d4262a7a35886cf8ac856457bbad8c0498c8d6 Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Tue, 22 Aug 2017 14:01:07 -0300 -Subject: [PATCH 40] Fix remaining return type of ifunc resolver declaration - -Since Martin Sebor's commit - -commit ee4e992ebe5f9712faedeefe8958b67d61eaa0f2 -Author: Martin Sebor -Date: Tue Aug 22 09:35:23 2017 -0600 - - Declare ifunc resolver to return a pointer to the same type as the target - function to help GCC detect incompatibilities between the two when it's - enhanced to do so. - -builds for powerpc64le fail in the declaration of some ifunc resolvers, -because the ifunc is declared with unmatching return types. One of the -declarations comes from the __ifunc_resolver macro, which was patched by -the aforementioned commit: - - /* Helper / base macros for indirect function symbols. */ - #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \ - classifier inhibit_stack_protector \ - __typeof (type_name) *name##_ifunc (arg) \ - -whereas the other comes from the unpatched __ifunc macro when -HAVE_GCC_IFUNC is not defined: - - # define __ifunc(type_name, name, expr, arg, init) \ - extern __typeof (type_name) name; \ - void *name##_ifunc (arg) __asm__ (#name); \ - -This patch changes the return type of the ifunc resolver in the __ifunc -macro, so that it matches the return type of the target function, -similarly to what the aforementioned commit does. - -Tested for powerpc64le and s390x with unpatched GCC. - - * include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc): - Change the return type of the ifunc resolver to match the return - type of the target function. - -(cherry picked from commit b513da7e80febbbfb8e58282075018652b6f7273) ---- - ChangeLog | 6 ++++++ - include/libc-symbols.h | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index ec9b9f5edb..6b09c61d5a 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-08-22 Gabriel F. T. Gomes -+ -+ * include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc): -+ Change the return type of the ifunc resolver to match the return -+ type of the target function. -+ - 2017-08-22 Martin Sebor - - * include/libc-symbols.h (__ifunc_resolver): Declare resolver -diff --git a/include/libc-symbols.h b/include/libc-symbols.h -index c50f9adec2..5bf57703a9 100644 ---- a/include/libc-symbols.h -+++ b/include/libc-symbols.h -@@ -810,7 +810,7 @@ for linking") - - # define __ifunc(type_name, name, expr, arg, init) \ - extern __typeof (type_name) name; \ -- void *name##_ifunc (arg) __asm__ (#name); \ -+ __typeof (type_name) *name##_ifunc (arg) __asm__ (#name); \ - __ifunc_resolver (type_name, name, expr, arg, init,) \ - __asm__ (".type " #name ", %gnu_indirect_function"); - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-41.patch b/srcpkgs/glibc/patches/glibc-upstream-41.patch deleted file mode 100644 index d92bae52d1..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-41.patch +++ /dev/null @@ -1,86 +0,0 @@ -From d37c951fde57e8acb320a9a7d437ba50a1fc3c8a Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Wed, 20 Sep 2017 15:10:26 -0300 -Subject: [PATCH 41] Let fpclassify use the builtin when optimizing for size - in C++ mode (bug 22146) - -When optimization for size is on (-Os), fpclassify does not use the -type-generic __builtin_fpclassify builtin, instead it uses __MATH_TG. -However, when library support for float128 is available, __MATH_TG uses -__builtin_types_compatible_p, which is not available in C++ mode. - -On the other hand, libstdc++ undefines (in cmath) many macros from -math.h, including fpclassify, so that it can provide its own functions. -However, during its configure tests, libstdc++ just tests for the -availability of the macros (it does not undefine them, nor does it -provide its own functions). - -Finally, when libstdc++ is configured with optimization for size -enabled, its configure tests include math.h and get the definition of -fpclassify that uses __MATH_TG (and __builtin_types_compatible_p). -Since libstdc++ does not undefine the macros during its configure tests, -they fail. - -This patch lets fpclassify use the builtin in C++ mode, even when -optimization for size is on. This allows the configure test in -libstdc++ to work. - -Tested for powerpc64le and x86_64. - - [BZ #22146] - math/math.h: Let fpclassify use the builtin in C++ mode, even - when optimazing for size. - -(cherry picked from commit c5c4a626098ec884b8527356abdf2a4bb7b6bf27) ---- - ChangeLog | 6 ++++++ - NEWS | 1 + - math/math.h | 8 +++++++- - 3 files changed, 14 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 6b09c61d5a..382674d5a3 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2017-09-22 Gabriel F. T. Gomes -+ -+ [BZ #22146] -+ math/math.h: Let fpclassify use the builtin in C++ mode, even -+ when optimazing for size. -+ - 2017-08-22 Gabriel F. T. Gomes - - * include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc): -diff --git a/NEWS b/NEWS -index 9bcb176171..48e2064380 100644 ---- a/NEWS -+++ b/NEWS -@@ -30,6 +30,7 @@ The following bugs are resolved with this release: - [21972] assert macro requires operator== (int) for its argument type - [22095] resolv: Fix memory leak with OOM during resolv.conf parsing - [22096] resolv: __resolv_conf_attach must not free passed conf object -+ [22146] Let fpclassify use the builtin when optimizing for size in C++ mode - - Version 2.26 - -diff --git a/math/math.h b/math/math.h -index 7c0fc6dbb3..f9348ec3ea 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -402,7 +402,13 @@ enum - - /* Return number of classification appropriate for X. */ - # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \ -- && !defined __OPTIMIZE_SIZE__ -+ && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus) -+ /* The check for __cplusplus allows the use of the builtin, even -+ when optimization for size is on. This is provided for -+ libstdc++, only to let its configure test work when it is built -+ with -Os. No further use of this definition of fpclassify is -+ expected in C++ mode, since libstdc++ provides its own version -+ of fpclassify in cmath (which undefines fpclassify). */ - # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \ - FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) - # else - diff --git a/srcpkgs/glibc/patches/glibc-upstream-42.patch b/srcpkgs/glibc/patches/glibc-upstream-42.patch deleted file mode 100644 index 5f913f8215..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-42.patch +++ /dev/null @@ -1,165 +0,0 @@ -From 548cc83c38a91852b1e44045ead3d20ccd5db4cf Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Thu, 28 Sep 2017 01:59:02 +0000 -Subject: [PATCH 42] Fix nearbyint arithmetic moved before feholdexcept (bug - 22225). - -In I -remarked on the possibility of arithmetic in various nearbyint -implementations being scheduled before feholdexcept calls, resulting -in spurious "inexact" exceptions. - -I'm now actually observing this occurring in glibc built for ARM with -GCC 7 (in fact, both copies of the same addition/subtraction sequence -being combined and moved out before the conditionals and -feholdexcept/fesetenv pairs), resulting in test failures. - -This patch makes the nearbyint implementations with this particular -feholdexcept / arithmetic / fesetenv pattern consistently use -math_opt_barrier on the function argument when first used in -arithmetic, and also consistently use math_force_eval before fesetenv -(the latter was generally already done, but the dbl-64/wordsize-64 -implementation used math_opt_barrier instead, and as -math_opt_barrier's intended effect is through its output value being -used, such a use that doesn't use the return value is suspect). - -Tested for x86_64 (--disable-multi-arch so more of these -implementations get used), and for ARM in a configuration where I saw -the problem scheduling. - - [BZ #22225] - * sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Use - math_opt_barrier on argument when doing arithmetic on it. - * sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint): - Likewise. Use math_force_eval not math_opt_barrier after - arithmetic. - * sysdeps/ieee754/flt-32/s_nearbyintf.c (__nearbyintf): Use - math_opt_barrier on argument when doing arithmetic on it. - * sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl): - Likewise. - -(cherry picked from commit f124cb381116b5809de198327690ad0bd8d1478e) ---- - ChangeLog | 13 +++++++++++++ - sysdeps/ieee754/dbl-64/s_nearbyint.c | 4 ++-- - sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c | 8 ++++---- - sysdeps/ieee754/flt-32/s_nearbyintf.c | 4 ++-- - sysdeps/ieee754/ldbl-128/s_nearbyintl.c | 4 ++-- - 5 files changed, 23 insertions(+), 10 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 382674d5a3..992722acdb 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,16 @@ -+2017-09-28 Joseph Myers -+ -+ [BZ #22225] -+ * sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Use -+ math_opt_barrier on argument when doing arithmetic on it. -+ * sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint): -+ Likewise. Use math_force_eval not math_opt_barrier after -+ arithmetic. -+ * sysdeps/ieee754/flt-32/s_nearbyintf.c (__nearbyintf): Use -+ math_opt_barrier on argument when doing arithmetic on it. -+ * sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl): -+ Likewise. -+ - 2017-09-22 Gabriel F. T. Gomes - - [BZ #22146] -diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c -index dec0c5d6ee..6e3f8316b1 100644 ---- a/sysdeps/ieee754/dbl-64/s_nearbyint.c -+++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c -@@ -48,7 +48,7 @@ __nearbyint (double x) - if (j0 < 0) - { - libc_feholdexcept (&env); -- w = TWO52[sx] + x; -+ w = TWO52[sx] + math_opt_barrier (x); - t = w - TWO52[sx]; - math_force_eval (t); - libc_fesetenv (&env); -@@ -65,7 +65,7 @@ __nearbyint (double x) - return x; /* x is integral */ - } - libc_feholdexcept (&env); -- w = TWO52[sx] + x; -+ w = TWO52[sx] + math_opt_barrier (x); - t = w - TWO52[sx]; - math_force_eval (t); - libc_fesetenv (&env); -diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c -index 8293819981..7d135b54e4 100644 ---- a/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c -+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c -@@ -42,9 +42,9 @@ __nearbyint(double x) - if(__builtin_expect(j0<52, 1)) { - if(j0<0) { - libc_feholdexcept (&env); -- double w = TWO52[sx]+x; -+ double w = TWO52[sx] + math_opt_barrier (x); - double t = w-TWO52[sx]; -- math_opt_barrier(t); -+ math_force_eval (t); - libc_fesetenv (&env); - return __copysign (t, x); - } -@@ -53,9 +53,9 @@ __nearbyint(double x) - else return x; /* x is integral */ - } - libc_feholdexcept (&env); -- double w = TWO52[sx]+x; -+ double w = TWO52[sx] + math_opt_barrier (x); - double t = w-TWO52[sx]; -- math_opt_barrier (t); -+ math_force_eval (t); - libc_fesetenv (&env); - return t; - } -diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c -index 5aebefafcf..b06df6b3c8 100644 ---- a/sysdeps/ieee754/flt-32/s_nearbyintf.c -+++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c -@@ -37,7 +37,7 @@ __nearbyintf(float x) - if(j0<23) { - if(j0<0) { - libc_feholdexceptf (&env); -- w = TWO23[sx]+x; -+ w = TWO23[sx] + math_opt_barrier (x); - t = w-TWO23[sx]; - math_force_eval (t); - libc_fesetenvf (&env); -@@ -50,7 +50,7 @@ __nearbyintf(float x) - else return x; /* x is integral */ - } - libc_feholdexceptf (&env); -- w = TWO23[sx]+x; -+ w = TWO23[sx] + math_opt_barrier (x); - t = w-TWO23[sx]; - math_force_eval (t); - libc_fesetenvf (&env); -diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c -index 1565a8183f..98a33d24a7 100644 ---- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c -+++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c -@@ -45,7 +45,7 @@ _Float128 __nearbyintl(_Float128 x) - if(j0<112) { - if(j0<0) { - feholdexcept (&env); -- w = TWO112[sx]+x; -+ w = TWO112[sx] + math_opt_barrier (x); - t = w-TWO112[sx]; - math_force_eval (t); - fesetenv (&env); -@@ -58,7 +58,7 @@ _Float128 __nearbyintl(_Float128 x) - else return x; /* x is integral */ - } - feholdexcept (&env); -- w = TWO112[sx]+x; -+ w = TWO112[sx] + math_opt_barrier (x); - t = w-TWO112[sx]; - math_force_eval (t); - fesetenv (&env); - diff --git a/srcpkgs/glibc/patches/glibc-upstream-43.patch b/srcpkgs/glibc/patches/glibc-upstream-43.patch deleted file mode 100644 index bac0a8617a..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-43.patch +++ /dev/null @@ -1,28 +0,0 @@ -From fdf58ebc60ce0eb459fd616241b52872b3571ac1 Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Sat, 30 Sep 2017 00:48:07 +0000 -Subject: [PATCH 43] Add missing bug fixes to list in NEWS file. - ---- - NEWS | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/NEWS b/NEWS -index 48e2064380..8e468c0369 100644 ---- a/NEWS -+++ b/NEWS -@@ -28,9 +28,13 @@ The following bugs are resolved with this release: - [21932] Unpaired __resolv_context_get in generic get*_r implementation - [21941] powerpc: Restrict xssqrtqp operands to Vector Registers - [21972] assert macro requires operator== (int) for its argument type -+ [21982] string: stratcliff.c: error: assuming signed overflow does not -+ occur with -O3 -+ [22051] libc: zero terminator in the middle of glibc's .eh_frame - [22095] resolv: Fix memory leak with OOM during resolv.conf parsing - [22096] resolv: __resolv_conf_attach must not free passed conf object - [22146] Let fpclassify use the builtin when optimizing for size in C++ mode -+ [22225] math: nearbyint arithmetic moved before feholdexcept - - Version 2.26 - - diff --git a/srcpkgs/glibc/patches/glibc-upstream-44.patch b/srcpkgs/glibc/patches/glibc-upstream-44.patch deleted file mode 100644 index 1e17b2709b..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-44.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 3f68c5c9b61600f0f85c75bac15b1520d5059359 Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Tue, 22 Aug 2017 00:59:43 +0000 -Subject: [PATCH 44] Fix sparc32 bits/long-double.h (bug 21987). - -My refactoring of long double information - -commit 0acb8a2a855395c25b1feef2470f4d7ca4bed589 -Author: Joseph Myers -Date: Wed Dec 14 18:27:56 2016 +0000 - - Refactor long double information into bits/long-double.h. - -resulted in sparc32 configurations installing the ldbl-opt version of -bits/long-double.h instead of the intended -sysdeps/unix/sysv/linux/sparc version. - -For sparc32 by itself, this is not a problem, since the ldbl-opt -version is correct for sparc32. However, both sparc32 and sparc64 are -supposed to install sets of headers that work for both of them, so -that a single sysroot, whichever order the libraries are built and -installed in, works for both. The effect of having the wrong version -installed is that you end up with a miscompiled sparc64 libstdc++ -which fails glibc's configure tests for the C++ compiler. - -This patch moves the header from sysdeps/unix/sysv/linux/sparc to -separate copies of the same file for sparc32 and sparc64, to ensure it -comes before ldbl-opt in the sysdeps directory ordering. - -Tested with build-many-glibcs.py for sparc64-linux-gnu and -sparcv9-linux-gnu. - - [BZ #21987] - * sysdeps/unix/sysv/linux/sparc/bits/long-double.h: Remove file - and copy to ... - * sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h: - ... here. - * sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h: - ... and here. - -(cherry picked from commit 80f91666fed71fa3dd5eb5618739147cc731bc89) ---- - ChangeLog | 10 +++++++++ - .../linux/sparc/{ => sparc32}/bits/long-double.h | 0 - .../sysv/linux/sparc/sparc64/bits/long-double.h | 26 ++++++++++++++++++++++ - 3 files changed, 36 insertions(+) - rename sysdeps/unix/sysv/linux/sparc/{ => sparc32}/bits/long-double.h (100%) - create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h - -diff --git a/ChangeLog b/ChangeLog -index 992722acdb..cc763ac065 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,13 @@ -+2017-08-22 Joseph Myers -+ -+ [BZ #21987] -+ * sysdeps/unix/sysv/linux/sparc/bits/long-double.h: Remove file -+ and copy to ... -+ * sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h: -+ ... here. -+ * sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h: -+ ... and here. -+ - 2017-09-28 Joseph Myers - - [BZ #22225] -diff --git a/sysdeps/unix/sysv/linux/sparc/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h -similarity index 100% -rename from sysdeps/unix/sysv/linux/sparc/bits/long-double.h -rename to sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h -diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h -new file mode 100644 -index 0000000000..094e05124b ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h -@@ -0,0 +1,26 @@ -+/* Properties of long double type. SPARC version. -+ Copyright (C) 2016-2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#include -+ -+#if !defined __NO_LONG_DOUBLE_MATH && __WORDSIZE == 32 -+# define __LONG_DOUBLE_MATH_OPTIONAL 1 -+# ifndef __LONG_DOUBLE_128__ -+# define __NO_LONG_DOUBLE_MATH 1 -+# endif -+#endif - diff --git a/srcpkgs/glibc/patches/glibc-upstream-45.patch b/srcpkgs/glibc/patches/glibc-upstream-45.patch deleted file mode 100644 index a076153703..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-45.patch +++ /dev/null @@ -1,250 +0,0 @@ -From 3b10c5d2abb0392d5ecfd865e2eb911ac109e36f Mon Sep 17 00:00:00 2001 -From: "Gabriel F. T. Gomes" -Date: Mon, 2 Oct 2017 14:46:35 -0300 -Subject: [PATCH 45] Add C++ versions of iscanonical for ldbl-96 and - ldbl-128ibm (bug 22235) - -All representations of floating-point numbers in types with IEC 60559 -binary exchange format are canonical. On the other hand, types with IEC -60559 extended formats, such as those implemented under ldbl-96 and -ldbl-128ibm, contain representations that are not canonical. - -TS 18661-1 introduced the type-generic macro iscanonical, which returns -whether a floating-point value is canonical or not. In Glibc, this -type-generic macro is implemented using the macro __MATH_TG, which, when -support for float128 is enabled, relies on __builtin_types_compatible_p -to select between floating-point types. However, this use of -iscanonical breaks C++ applications, because the builtin is only -available in C mode. - -This patch provides a C++ implementation of iscanonical that relies on -function overloading, rather than builtins, to select between -floating-point types. - -Unlike the C++ implementations for iszero and issignaling, this -implementation ignores __NO_LONG_DOUBLE_MATH. The double type always -matches IEC 60559 double format, which is always canonical. Thus, when -double and long double are the same (__NO_LONG_DOUBLE_MATH), iscanonical -always returns 1 and is not implemented with __MATH_TG. - -Tested for powerpc64, powerpc64le and x86_64. - - [BZ #22235] - * math/math.h: Trivial fix for unbalanced parentheses in comment. - * math/Makefile [CXX] (tests): Add test-math-iscanonical.cc. - (CFLAGS-test-math-iscanonical.cc): New variable. - * math/test-math-iscanonical.cc: New file. - * sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical): - Provide a C++ implementation based on function overloading, - rather than using __MATH_TG, which uses C-only builtins. - * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical): - Likewise. - * sysdeps/powerpc/powerpc64le/Makefile - (CFLAGS-test-math-iscanonical.cc): New variable. - -(cherry picked from commit aa0235dfdebffe9b338deba51f3ba563ee9b433d) ---- - ChangeLog | 15 ++++++++ - NEWS | 1 + - math/Makefile | 4 ++- - math/math.h | 2 +- - math/test-math-iscanonical.cc | 48 ++++++++++++++++++++++++++ - sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h | 21 +++++++++-- - sysdeps/ieee754/ldbl-96/bits/iscanonical.h | 19 +++++++++- - sysdeps/powerpc/powerpc64le/Makefile | 1 + - 8 files changed, 106 insertions(+), 5 deletions(-) - create mode 100644 math/test-math-iscanonical.cc - -diff --git a/ChangeLog b/ChangeLog -index cc763ac065..fea4fd0cd6 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,18 @@ -+2017-10-03 Gabriel F. T. Gomes -+ -+ [BZ #22235] -+ * math/math.h: Trivial fix for unbalanced parentheses in comment. -+ * math/Makefile [CXX] (tests): Add test-math-iscanonical.cc. -+ (CFLAGS-test-math-iscanonical.cc): New variable. -+ * math/test-math-iscanonical.cc: New file. -+ * sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical): -+ Provide a C++ implementation based on function overloading, -+ rather than using __MATH_TG, which uses C-only builtins. -+ * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical): -+ Likewise. -+ * sysdeps/powerpc/powerpc64le/Makefile -+ (CFLAGS-test-math-iscanonical.cc): New variable. -+ - 2017-08-22 Joseph Myers - - [BZ #21987] -diff --git a/NEWS b/NEWS -index 8e468c0369..5b05edeb4f 100644 ---- a/NEWS -+++ b/NEWS -@@ -35,6 +35,7 @@ The following bugs are resolved with this release: - [22096] resolv: __resolv_conf_attach must not free passed conf object - [22146] Let fpclassify use the builtin when optimizing for size in C++ mode - [22225] math: nearbyint arithmetic moved before feholdexcept -+ [22235] Add C++ versions of iscanonical for ldbl-96 and ldbl-128ibm - - Version 2.26 - -diff --git a/math/Makefile b/math/Makefile -index 0130fcf38b..2c17c68eda 100644 ---- a/math/Makefile -+++ b/math/Makefile -@@ -203,7 +203,8 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \ - test-signgam-ullong-static test-signgam-ullong-init-static - - ifneq (,$(CXX)) --tests += test-math-isinff test-math-iszero test-math-issignaling -+tests += test-math-isinff test-math-iszero test-math-issignaling \ -+ test-math-iscanonical - endif - - ifneq (no,$(PERL)) -@@ -351,6 +352,7 @@ CFLAGS-test-signgam-ullong-init-static.c = -std=c99 - CFLAGS-test-math-isinff.cc = -std=gnu++11 - CFLAGS-test-math-iszero.cc = -std=gnu++11 - CFLAGS-test-math-issignaling.cc = -std=gnu++11 -+CFLAGS-test-math-iscanonical.cc = -std=gnu++11 - - CFLAGS-test-iszero-excess-precision.c = -fexcess-precision=standard - CFLAGS-test-iseqsig-excess-precision.c = -fexcess-precision=standard -diff --git a/math/math.h b/math/math.h -index f9348ec3ea..2b216c6da1 100644 ---- a/math/math.h -+++ b/math/math.h -@@ -488,7 +488,7 @@ enum - other hand, overloading provides the means to distinguish between - the floating-point types. The overloading resolution will match - the correct parameter (regardless of type qualifiers (i.e.: const -- and volatile). */ -+ and volatile)). */ - extern "C++" { - inline int issignaling (float __val) { return __issignalingf (__val); } - inline int issignaling (double __val) { return __issignaling (__val); } -diff --git a/math/test-math-iscanonical.cc b/math/test-math-iscanonical.cc -new file mode 100644 -index 0000000000..aba68acb4f ---- /dev/null -+++ b/math/test-math-iscanonical.cc -@@ -0,0 +1,48 @@ -+/* Test for the C++ implementation of iscanonical. -+ Copyright (C) 2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#define _GNU_SOURCE 1 -+#include -+#include -+ -+static bool errors; -+ -+template -+static void -+check_type () -+{ -+ T val = 0; -+ -+ /* Check if iscanonical is available in C++ mode (bug 22235). */ -+ if (iscanonical (val) == 0) -+ errors++; -+} -+ -+static int -+do_test (void) -+{ -+ check_type (); -+ check_type (); -+ check_type (); -+#if __HAVE_DISTINCT_FLOAT128 -+ check_type<_Float128> (); -+#endif -+ return errors; -+} -+ -+#include -diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h -index 7ddb368d26..f756857c03 100644 ---- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h -+++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h -@@ -37,5 +37,22 @@ extern int __iscanonicall (long double __x) - conversion, before being discarded; in IBM long double, there are - encodings that are not consistently handled as corresponding to any - particular value of the type, and we return 0 for those. */ --# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) --#endif -+# ifndef __cplusplus -+# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) -+# else -+/* In C++ mode, __MATH_TG cannot be used, because it relies on -+ __builtin_types_compatible_p, which is a C-only builtin. On the -+ other hand, overloading provides the means to distinguish between -+ the floating-point types. The overloading resolution will match -+ the correct parameter (regardless of type qualifiers (i.e.: const -+ and volatile)). */ -+extern "C++" { -+inline int iscanonical (float __val) { return __iscanonicalf (__val); } -+inline int iscanonical (double __val) { return __iscanonical (__val); } -+inline int iscanonical (long double __val) { return __iscanonicall (__val); } -+# if __HAVE_DISTINCT_FLOAT128 -+inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } -+# endif -+} -+# endif /* __cplusplus */ -+#endif /* __NO_LONG_DOUBLE_MATH */ -diff --git a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h -index 4a4f4ad024..cfa36a0c2a 100644 ---- a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h -+++ b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h -@@ -34,4 +34,21 @@ extern int __iscanonicall (long double __x) - conversion, before being discarded; in extended precision, there - are encodings that are not consistently handled as corresponding to - any particular value of the type, and we return 0 for those. */ --#define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) -+#ifndef __cplusplus -+# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) -+#else -+/* In C++ mode, __MATH_TG cannot be used, because it relies on -+ __builtin_types_compatible_p, which is a C-only builtin. On the -+ other hand, overloading provides the means to distinguish between -+ the floating-point types. The overloading resolution will match -+ the correct parameter (regardless of type qualifiers (i.e.: const -+ and volatile)). */ -+extern "C++" { -+inline int iscanonical (float __val) { return __iscanonicalf (__val); } -+inline int iscanonical (double __val) { return __iscanonical (__val); } -+inline int iscanonical (long double __val) { return __iscanonicall (__val); } -+# if __HAVE_DISTINCT_FLOAT128 -+inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } -+# endif -+} -+#endif /* __cplusplus */ -diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile -index dea2290736..cf2dbfb673 100644 ---- a/sysdeps/powerpc/powerpc64le/Makefile -+++ b/sysdeps/powerpc/powerpc64le/Makefile -@@ -16,6 +16,7 @@ $(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128 - $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128 - $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128 - CFLAGS-libm-test-support-float128.c += -mfloat128 -+CFLAGS-test-math-iscanonical.cc += -mfloat128 - CFLAGS-test-math-issignaling.cc += -mfloat128 - CFLAGS-test-math-iszero.cc += -mfloat128 - $(objpfx)test-float128% $(objpfx)test-ifloat128% $(objpfx)test-math-iszero: \ - diff --git a/srcpkgs/glibc/patches/glibc-upstream-46.patch b/srcpkgs/glibc/patches/glibc-upstream-46.patch deleted file mode 100644 index 85a1ff352f..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-46.patch +++ /dev/null @@ -1,64 +0,0 @@ -From dd3a7239fddff81ac31373d69978d7aa1902c65f Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" -Date: Tue, 3 Oct 2017 17:41:32 -0700 -Subject: [PATCH 46] test-math-iscanonical.cc: Replace bool with int -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Fix GCC 7 compilation error: - -test-math-iscanonical.cc: In function ‘void check_type()’: -test-math-iscanonical.cc:33:11: error: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Werror=deprecated] - errors++; - ^~ - -Since not all non-zero error counts are errors, return errors != 0 -instead. - - * math/test-math-iscanonical.cc (error): Replace bool with int. - (do_test): Return errors != 0. - -(cherry picked from commit cdd4155d6c527c00a89606385859984e35bd2910 and - commit 758f1bfa2a1bccb52f1b3e97444a367d35aceaee) ---- - ChangeLog | 5 +++++ - math/test-math-iscanonical.cc | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index fea4fd0cd6..d7a185e99d 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,8 @@ -+2017-10-04 H.J. Lu -+ -+ * math/test-math-iscanonical.cc (error): Replace bool with int. -+ (do_test): Return errors != 0. -+ - 2017-10-03 Gabriel F. T. Gomes - - [BZ #22235] -diff --git a/math/test-math-iscanonical.cc b/math/test-math-iscanonical.cc -index aba68acb4f..4cfb1c5055 100644 ---- a/math/test-math-iscanonical.cc -+++ b/math/test-math-iscanonical.cc -@@ -20,7 +20,7 @@ - #include - #include - --static bool errors; -+static int errors; - - template - static void -@@ -42,7 +42,7 @@ do_test (void) - #if __HAVE_DISTINCT_FLOAT128 - check_type<_Float128> (); - #endif -- return errors; -+ return errors != 0; - } - - #include - diff --git a/srcpkgs/glibc/patches/glibc-upstream-47.patch b/srcpkgs/glibc/patches/glibc-upstream-47.patch deleted file mode 100644 index 800676ee91..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-47.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 6e1ea21501eac981204c3cc8212d45998f74983c Mon Sep 17 00:00:00 2001 -From: Carlos O'Donell -Date: Thu, 28 Sep 2017 11:05:18 -0600 -Subject: [PATCH 47] malloc: Fix tcache leak after thread destruction [BZ - #22111] - -The malloc tcache added in 2.26 will leak all of the elements remaining -in the cache and the cache structure itself when a thread exits. The -defect is that we do not set tcache_shutting_down early enough, and the -thread simply recreates the tcache and places the elements back onto a -new tcache which is subsequently lost as the thread exits (unfreed -memory). The fix is relatively simple, move the setting of -tcache_shutting_down earlier in tcache_thread_freeres. We add a test -case which uses mallinfo and some heuristics to look for unaccounted for -memory usage between the start and end of a thread start/join loop. It -is very reliable at detecting that there is a leak given the number of -iterations. Without the fix the test will consume 122MiB of leaked -memory. - -(cherry picked from commit 1e26d35193efbb29239c710a4c46a64708643320) ---- - ChangeLog | 9 ++++ - malloc/Makefile | 3 ++ - malloc/malloc.c | 8 +-- - malloc/tst-malloc-tcache-leak.c | 112 ++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 129 insertions(+), 3 deletions(-) - create mode 100644 malloc/tst-malloc-tcache-leak.c - -diff --git a/ChangeLog b/ChangeLog -index d7a185e99d..bfcdc1ebbf 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,12 @@ -+2017-10-06 Carlos O'Donell -+ -+ [BZ #22111] -+ * malloc/malloc.c (tcache_shutting_down): Use bool type. -+ (tcache_thread_freeres): Set tcache_shutting_down before -+ freeing the tcache. -+ * malloc/Makefile (tests): Add tst-malloc-tcache-leak. -+ * malloc/tst-malloc-tcache-leak.c: New file. -+ - 2017-10-04 H.J. Lu - - * math/test-math-iscanonical.cc (error): Replace bool with int. -diff --git a/malloc/Makefile b/malloc/Makefile -index 3fa395b949..9e23db9343 100644 ---- a/malloc/Makefile -+++ b/malloc/Makefile -@@ -34,6 +34,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \ - tst-interpose-nothread \ - tst-interpose-thread \ - tst-alloc_buffer \ -+ tst-malloc-tcache-leak \ - - tests-static := \ - tst-interpose-static-nothread \ -@@ -242,3 +243,5 @@ tst-dynarray-fail-ENV = MALLOC_TRACE=$(objpfx)tst-dynarray-fail.mtrace - $(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out - $(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray-fail.mtrace > $@; \ - $(evaluate-test) -+ -+$(objpfx)tst-malloc-tcache-leak: $(shared-thread-library) -diff --git a/malloc/malloc.c b/malloc/malloc.c -index e3ff778113..01ec1571b9 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -2952,7 +2952,7 @@ typedef struct tcache_perthread_struct - tcache_entry *entries[TCACHE_MAX_BINS]; - } tcache_perthread_struct; - --static __thread char tcache_shutting_down = 0; -+static __thread bool tcache_shutting_down = false; - static __thread tcache_perthread_struct *tcache = NULL; - - /* Caller must ensure that we know tc_idx is valid and there's room -@@ -2989,8 +2989,12 @@ tcache_thread_freeres (void) - if (!tcache) - return; - -+ /* Disable the tcache and prevent it from being reinitialized. */ - tcache = NULL; -+ tcache_shutting_down = true; - -+ /* Free all of the entries and the tcache itself back to the arena -+ heap for coalescing. */ - for (i = 0; i < TCACHE_MAX_BINS; ++i) - { - while (tcache_tmp->entries[i]) -@@ -3002,8 +3006,6 @@ tcache_thread_freeres (void) - } - - __libc_free (tcache_tmp); -- -- tcache_shutting_down = 1; - } - text_set_element (__libc_thread_subfreeres, tcache_thread_freeres); - -diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c -new file mode 100644 -index 0000000000..22c679b65b ---- /dev/null -+++ b/malloc/tst-malloc-tcache-leak.c -@@ -0,0 +1,112 @@ -+/* Bug 22111: Test that threads do not leak their per thread cache. -+ Copyright (C) 2015-2017 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+/* The point of this test is to start and exit a large number of -+ threads, while at the same time looking to see if the used -+ memory grows with each round of threads run. If the memory -+ grows above some linear bound we declare the test failed and -+ that the malloc implementation is leaking memory with each -+ thread. This is a good indicator that the thread local cache -+ is leaking chunks. */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+void * -+worker (void *data) -+{ -+ void *ret; -+ /* Allocate an arbitrary amount of memory that is known to fit into -+ the thread local cache (tcache). If we have at least 64 bins -+ (default e.g. TCACHE_MAX_BINS) we should be able to allocate 32 -+ bytes and force malloc to fill the tcache. We are assuming tcahce -+ init happens at the first small alloc, but it might in the future -+ be deferred to some other point. Therefore to future proof this -+ test we include a full alloc/free/alloc cycle for the thread. We -+ need a compiler barrier to avoid the removal of the useless -+ alloc/free. We send some memory back to main to have the memory -+ freed after the thread dies, as just another check that the chunks -+ that were previously in the tcache are still OK to free after -+ thread death. */ -+ ret = xmalloc (32); -+ __asm__ volatile ("" ::: "memory"); -+ free (ret); -+ return (void *) xmalloc (32); -+} -+ -+static int -+do_test (void) -+{ -+ pthread_t *thread; -+ struct mallinfo info_before, info_after; -+ void *retval; -+ -+ /* This is an arbitrary choice. We choose a total of THREADS -+ threads created and joined. This gives us enough iterations to -+ show a leak. */ -+ int threads = 100000; -+ -+ /* Avoid there being 0 malloc'd data at this point by allocating the -+ pthread_t required to run the test. */ -+ thread = (pthread_t *) xcalloc (1, sizeof (pthread_t)); -+ -+ info_before = mallinfo (); -+ -+ assert (info_before.uordblks != 0); -+ -+ printf ("INFO: %d (bytes) are in use before starting threads.\n", -+ info_before.uordblks); -+ -+ for (int loop = 0; loop < threads; loop++) -+ { -+ *thread = xpthread_create (NULL, worker, NULL); -+ retval = xpthread_join (*thread); -+ free (retval); -+ } -+ -+ info_after = mallinfo (); -+ printf ("INFO: %d (bytes) are in use after all threads joined.\n", -+ info_after.uordblks); -+ -+ /* We need to compare the memory in use before and the memory in use -+ after starting and joining THREADS threads. We almost always grow -+ memory slightly, but not much. Consider that if even 1-byte leaked -+ per thread we'd have THREADS bytes of additional memory, and in -+ general the in-use at the start of main is quite low. We will -+ always leak a full malloc chunk, and never just 1-byte, therefore -+ anything above "+ threads" from the start (constant offset) is a -+ leak. Obviously this assumes no thread-related malloc'd internal -+ libc data structures persist beyond the thread death, and any that -+ did would limit the number of times you could call pthread_create, -+ which is a QoI we'd want to detect and fix. */ -+ if (info_after.uordblks > (info_before.uordblks + threads)) -+ FAIL_EXIT1 ("Memory usage after threads is too high.\n"); -+ -+ /* Did not detect excessive memory usage. */ -+ free (thread); -+ exit (0); -+} -+ -+#include - diff --git a/srcpkgs/glibc/patches/glibc-upstream-48.patch b/srcpkgs/glibc/patches/glibc-upstream-48.patch deleted file mode 100644 index 795cea2b41..0000000000 --- a/srcpkgs/glibc/patches/glibc-upstream-48.patch +++ /dev/null @@ -1,21 +0,0 @@ -From d5c6dea2d5b4b5c64625c5386f6baec7bf2d89b3 Mon Sep 17 00:00:00 2001 -From: Carlos O'Donell -Date: Fri, 6 Oct 2017 13:31:05 -0700 -Subject: [PATCH 48] Update NEWS for bug 22111. - ---- - NEWS | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/NEWS b/NEWS -index 5b05edeb4f..d6d1f90008 100644 ---- a/NEWS -+++ b/NEWS -@@ -33,6 +33,7 @@ The following bugs are resolved with this release: - [22051] libc: zero terminator in the middle of glibc's .eh_frame - [22095] resolv: Fix memory leak with OOM during resolv.conf parsing - [22096] resolv: __resolv_conf_attach must not free passed conf object -+ [22111] malloc: per thread cache is not returned when thread exits - [22146] Let fpclassify use the builtin when optimizing for size in C++ mode - [22225] math: nearbyint arithmetic moved before feholdexcept - [22235] Add C++ versions of iscanonical for ldbl-96 and ldbl-128ibm diff --git a/srcpkgs/glibc/template b/srcpkgs/glibc/template index 4865c8bcc7..ec3687403b 100644 --- a/srcpkgs/glibc/template +++ b/srcpkgs/glibc/template @@ -1,14 +1,14 @@ # Template file for 'glibc' pkgname=glibc -version=2.26 -revision=3 +version=2.28 +revision=1 bootstrap=yes short_desc="The GNU C library" maintainer="Juan RP " homepage="http://www.gnu.org/software/libc" -license="GPL-2, LGPL-2.1, BSD" +license="GPL-2.0-or-later, LGPL-2.1-or-later, BSD-3-Clause" distfiles="${GNU_SITE}/glibc/glibc-${version}.tar.xz" -checksum=e54e0a934cd2bc94429be79da5e9385898d2306b9eaf3c92d5a77af96190f6bd +checksum=b1900051afad76f7a4f73e71413df4826dce085ef8ddb785a945b66d7d513082 patch_args="-Np1" # Do not strip these files, objcopy errors out. nostrip_files="