]> sourceware.org Git - glibc.git/log
glibc.git
27 hours agoUse Linux 6.11 in build-many-glibcs.py
Adhemerval Zanella [Tue, 8 Oct 2024 18:45:23 +0000 (15:45 -0300)]
Use Linux 6.11 in build-many-glibcs.py

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
47 hours agoFix header guard in sysdeps/mach/hurd/x86_64/vm_param.h
Joseph Myers [Wed, 9 Oct 2024 17:14:58 +0000 (17:14 +0000)]
Fix header guard in sysdeps/mach/hurd/x86_64/vm_param.h

GCC mainline produces a -Wheader-guard error building for x86_64-gnu.
Fix what seems to be incorrect macro naming in the #ifndef
conditional.

Tested with build-many-glibc.py for x86_64-gnu (GCC mainline).

Message-ID: <fd800046-5ecb-ebd5-4df1-29d4eb3d5433@redhat.com>

2 days agort: more clock_nanosleep tests addendum
DJ Delorie [Tue, 8 Oct 2024 18:30:21 +0000 (14:30 -0400)]
rt: more clock_nanosleep tests addendum

Forgot to change the first-line description.

2 days agort: more clock_nanosleep tests
DJ Delorie [Wed, 18 Sep 2024 02:52:37 +0000 (22:52 -0400)]
rt: more clock_nanosleep tests

Test that clock_nanosleep rejects out of range time values.

Test that clock_nanosleep actually sleeps for at least the
requested time relative to the requested clock.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 days agostdlib: Make abort/_Exit AS-safe (BZ 26275)
Adhemerval Zanella [Thu, 3 Oct 2024 18:41:10 +0000 (15:41 -0300)]
stdlib: Make abort/_Exit AS-safe (BZ 26275)

The recursive lock used on abort does not synchronize with a new process
creation (either by fork-like interfaces or posix_spawn ones), nor it
is reinitialized after fork().

Also, the SIGABRT unblock before raise() shows another race condition,
where a fork or posix_spawn() call by another thread, just after the
recursive lock release and before the SIGABRT signal, might create
programs with a non-expected signal mask.  With the default option
(without POSIX_SPAWN_SETSIGDEF), the process can see SIG_DFL for
SIGABRT, where it should be SIG_IGN.

To fix the AS-safe, raise() does not change the process signal mask,
and an AS-safe lock is used if a SIGABRT is installed or the process
is blocked or ignored.  With the signal mask change removal,
there is no need to use a recursive loc.  The lock is also taken on
both _Fork() and posix_spawn(), to avoid the spawn process to see the
abort handler as SIG_DFL.

A read-write lock is used to avoid serialize _Fork and posix_spawn
execution.  Both sigaction (SIGABRT) and abort() requires to lock
as writer (since both change the disposition).

The fallback is also simplified: there is no need to use a loop of
ABORT_INSTRUCTION after _exit() (if the syscall does not terminate the
process, the system is broken).

The proposed fix changes how setjmp works on a SIGABRT handler, where
glibc does not save the signal mask.  So usage like the below will now
always abort.

  static volatile int chk_fail_ok;
  static jmp_buf chk_fail_buf;

  static void
  handler (int sig)
  {
    if (chk_fail_ok)
      {
        chk_fail_ok = 0;
        longjmp (chk_fail_buf, 1);
      }
    else
      _exit (127);
  }
  [...]
  signal (SIGABRT, handler);
  [....]
  chk_fail_ok = 1;
  if (! setjmp (chk_fail_buf))
    {
      // Something that can calls abort, like a failed fortify function.
      chk_fail_ok = 0;
      printf ("FAIL\n");
    }

Such cases will need to use sigsetjmp instead.

The _dl_start_profile calls sigaction through _profil, and to avoid
pulling abort() on loader the call is replaced with __libc_sigaction.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 days agolinux: Use GLRO(dl_vdso_time) on time
Adhemerval Zanella [Wed, 4 Sep 2024 13:22:44 +0000 (10:22 -0300)]
linux: Use GLRO(dl_vdso_time) on time

The BZ#24967 fix (1bdda52fe92fd01b424c) missed the time for
architectures that define USE_IFUNC_TIME.  Although it is not
an issue, since there is no pointer mangling, there is also no need
to call dl_vdso_vsym since the vDSO setup was already done by the
loader.

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 days agolinux: Use GLRO(dl_vdso_gettimeofday) on gettimeofday
Adhemerval Zanella [Wed, 4 Sep 2024 13:10:31 +0000 (10:10 -0300)]
linux: Use GLRO(dl_vdso_gettimeofday) on gettimeofday

The BZ#24967 fix (1bdda52fe92fd01b424c) missed the gettimeofday for
architectures that define USE_IFUNC_GETTIMEOFDAY.  Although it is not
an issue, since there is no pointer mangling, there is also no need
to call dl_vdso_vsym since the vDSO setup was already done by the
loader.

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 days agoS390: Don't use r11 for cu-instructions as used as frame-pointer. [BZ# 32192]
Stefan Liebler [Fri, 27 Sep 2024 08:26:29 +0000 (10:26 +0200)]
S390: Don't use r11 for cu-instructions as used as frame-pointer. [BZ# 32192]

Building the s390 specific iconv modules - utf16-utf32-z9.c, utf8-utf32-z9.c
and utf8-utf16-z9.c - with -fno-omit-frame-pointer leads to a build error
"error: %r11 cannot be used in 'asm' here" as r11 is needed as frame-pointer.

The cuXY-instructions need two even-odd register pairs. Therefore the register
pinning is used. This patch just uses a different register pair.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 days agostdio-common/Makefile: Fix FAIL: lint-makefiles
H.J. Lu [Tue, 8 Oct 2024 00:46:45 +0000 (08:46 +0800)]
stdio-common/Makefile: Fix FAIL: lint-makefiles

Fix stdio-common/Makefile:

@@ -224,12 +224,12 @@
   tst-freopen4 \
   tst-freopen5 \
   tst-freopen6 \
+  tst-freopen7 \
   tst-freopen64-2 \
   tst-freopen64-3 \
   tst-freopen64-4 \
   tst-freopen64-6 \
   tst-freopen64-7 \
-  tst-freopen7 \
   tst-fseek \
   tst-fwrite \
   tst-fwrite-memstrm \

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoFix whitespace related license issues.
Carlos O'Donell [Mon, 7 Oct 2024 22:04:22 +0000 (18:04 -0400)]
Fix whitespace related license issues.

Several copies of the licenses in files contained whitespace related
problems.  Two cases are addressed here, the first is two spaces
after a period which appears between "PURPOSE." and "See". The other
is a space after the last forward slash in the URL. Both issues are
corrected and the licenses now match the official textual description
of the license (and the other license in the sources).

Since these whitespaces changes do not alter the paragraph structure of
the license, nor create new sentences, they do not change the license.

3 days agoAdd freopen special-case tests: thread cancellation
Joseph Myers [Mon, 7 Oct 2024 19:44:25 +0000 (19:44 +0000)]
Add freopen special-case tests: thread cancellation

Add tests of freopen adding or removing "c" (non-cancelling I/O) from
the mode string (so completing my planned tests of freopen with
different features used in the mode strings).  Note that it's in the
nature of the uncertain time at which cancellation might act (possibly
during freopen, possibly during subsequent reads) that these can leak
memory or file descriptors, so these do not include leak tests.

Tested for x86_64.

7 days agohurd: Add missing va_end call in fcntl implementation. [BZ #32234]
Bruno Haible [Thu, 3 Oct 2024 11:25:29 +0000 (13:25 +0200)]
hurd: Add missing va_end call in fcntl implementation. [BZ #32234]

* sysdeps/mach/hurd/fcntl.c (__libc_fcntl): Add va_end call in two code paths.

9 days agoriscv: align .preinit_array (bug 32228)
Andreas Schwab [Wed, 2 Oct 2024 09:19:50 +0000 (11:19 +0200)]
riscv: align .preinit_array (bug 32228)

The section contains an array of pointers, so it should be aligned to
pointer size.

10 days agolinux: sparc: Fix clone for LEON/sparcv8 (BZ 31394)
Adhemerval Zanella [Mon, 2 Sep 2024 19:58:51 +0000 (16:58 -0300)]
linux: sparc: Fix clone for LEON/sparcv8 (BZ 31394)

The sparc clone mitigation (faeaa3bc9f76030) added the use of
flushw, which is not support by LEON/sparcv8.  As discussed on
the libc-alpha, 'ta 3' is a working alternative [1].

[1] https://sourceware.org/pipermail/libc-alpha/2024-August/158905.html

Checked with a build for sparcv8-linux-gnu targetting leon.

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
10 days agolinux: sparc: Fix syscall_cancel for LEON
Adhemerval Zanella [Mon, 2 Sep 2024 19:58:24 +0000 (16:58 -0300)]
linux: sparc: Fix syscall_cancel for LEON

LEON2/LEON3 are both sparcv8, which does not support branch hints
(bne,pn) nor the return instruction.

Checked with a build for sparcv8-linux-gnu targetting leon. I also
checked some cancellation tests with qemu-system (targeting LEON3).

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
10 days agomath: Improve layout of expf data
Wilco Dijkstra [Wed, 24 Jul 2024 14:17:47 +0000 (15:17 +0100)]
math: Improve layout of expf data

GCC aligns global data to 16 bytes if their size is >= 16 bytes.  This patch
changes the exp2f_data struct slightly so that the fields are better aligned.
As a result on targets that support them, load-pair instructions accessing
poly_scaled and invln2_scaled are now 16-byte aligned.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
10 days agoDisable _TIME_BITS if the compiler defaults to it
Adhemerval Zanella [Tue, 10 Sep 2024 12:22:19 +0000 (09:22 -0300)]
Disable _TIME_BITS if the compiler defaults to it

Even though building glibc with 64 bit time_t flags is not supported,
and the usual way is to patch the build system to avoid it; some
systems do enable it by default, and it increases the requirements
to build glibc in such cases (it also does not help newcomers when
trying to build glibc).

The conform namespace and linknamespace tests also do not expect
that flag to be set by default, so disable it as well.

Checked with a build/check for major ABI and some (i386, arm,
mipsel, hppa) with a toolchain that has LFS flags by default.
Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agoDisable _FILE_OFFSET_BITS if the compiler defaults to it
Adhemerval Zanella [Tue, 10 Sep 2024 12:22:18 +0000 (09:22 -0300)]
Disable _FILE_OFFSET_BITS if the compiler defaults to it

Even though building glibc with LFS flags is not supported, and the
the usual way is to patch the build system to avoid it [1]; some system
do enable it by default, and it increases the requirements to build
glibc in such cases (it also does not help newcomers when trying
to build glibc).

The conform namespace and linknamespace tests also do not expect
that flag to be set by default, so disable it as well.

Checked with a build/check for major ABI and some (i386, arm,
mipsel, hppa) with a toolchain that has LFS flags by default.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=31624
Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agoDo not use -Wp to disable fortify (BZ 31928)
Adhemerval Zanella [Tue, 10 Sep 2024 12:22:17 +0000 (09:22 -0300)]
Do not use -Wp to disable fortify (BZ 31928)

The -Wp does not work properly if the compiler is configured to enable
fortify by default, since it bypasses the compiler driver (which defines
the fortify flags in this case).

This patch is similar to the one used on Ubuntu [1].

I checked with a build for x86_64-linux-gnu, i686-linux-gnu,
aarch64-linux-gnu, s390x-linux-gnu, and riscv64-linux-gnu with
gcc-13 that enables the fortify by default.

Co-authored-by: Matthias Klose <matthias.klose@canonical.com>
[1] https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/glibc/tree/debian/patches/ubuntu/fix-fortify-source.patch
Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agolibio: Set _vtable_offset before calling _IO_link_in [BZ #32148]
H.J. Lu [Sat, 7 Sep 2024 15:32:32 +0000 (08:32 -0700)]
libio: Set _vtable_offset before calling _IO_link_in [BZ #32148]

Since _IO_vtable_offset is used to detect the old binaries, set it
in _IO_old_file_init_internal before calling _IO_link_in which checks
_IO_vtable_offset.  Add a glibc 2.0 test with copy relocation on
_IO_stderr_@GLIBC_2.0 to verify that fopen won't cause memory corruption.
This fixes BZ #32148.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
10 days agoAdd a new fwrite test that exercises buffer overflow
Tulio Magno Quites Machado Filho [Thu, 26 Sep 2024 14:30:29 +0000 (11:30 -0300)]
Add a new fwrite test that exercises buffer overflow

Exercises fwrite's internal buffer when doing a file operation.
The new test, exercises 2 overflow behaviors:

1. Call fwrite multiple times making usage of fwrite's internal buffer.
   The total number of bytes written is larger than fwrite's internal
   buffer, forcing an automatic flush.

2. Call fwrite a single time with an amount of data that is larger than
   fwrite's internal buffer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
11 days agox86/string: Fixup alignment of main loop in str{n}cmp-evex [BZ #32212]
Noah Goldstein [Fri, 27 Sep 2024 22:50:10 +0000 (15:50 -0700)]
x86/string: Fixup alignment of main loop in str{n}cmp-evex [BZ #32212]

The loop should be aligned to 32-bytes so that it can ideally run out
the DSB. This is particularly important on Skylake-Server where
deficiencies in it's DSB implementation make it prone to not being
able to run loops out of the DSB.

For example running strcmp-evex on 200Mb string:

32-byte aligned loop:
    - 43,399,578,766      idq.dsb_uops
not 32-byte aligned loop:
    - 6,060,139,704       idq.dsb_uops

This results in a 25% performance degradation for the non-aligned
version.

The fix is to just ensure the code layout is such that the loop is
aligned. (Which was previously the case but was accidentally dropped
in 84e7c46df).

NB: The fix was actually 64-byte alignment. This is because 64-byte
alignment generally produces more stable performance than 32-byte
aligned code (cache line crosses can affect perf), so if we are going
past 16-byte alignmnent, might as well go to 64. 64-byte alignment
also matches most other functions we over-align, so it creates a
common point of optimization.

Times are reported as ratio of Time_With_Patch /
Time_Without_Patch. Lower is better.

The values being reported is the geometric mean of the ratio across
all tests in bench-strcmp and bench-strncmp.

Note this patch is only attempting to improve the Skylake-Server
strcmp for long strings. The rest of the numbers are only to test for
regressions.

Tigerlake Results Strings <= 512:
    strcmp : 1.026
    strncmp: 0.949

Tigerlake Results Strings > 512:
    strcmp : 0.994
    strncmp: 0.998

Skylake-Server Results Strings <= 512:
    strcmp : 0.945
    strncmp: 0.943

Skylake-Server Results Strings > 512:
    strcmp : 0.778
    strncmp: 1.000

The 2.6% regression on TGL-strcmp is due to slowdowns caused by
changes in alignment of code handling small sizes (most on the
page-cross logic). These should be safe to ignore because 1) We
previously only 16-byte aligned the function so this behavior is not
new and was essentially up to chance before this patch and 2) this
type of alignment related regression on small sizes really only comes
up in tight micro-benchmark loops and is unlikely to have any affect
on realworld performance.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
12 days agostdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTED
Florian Weimer [Sat, 28 Sep 2024 19:06:11 +0000 (21:06 +0200)]
stdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTED

The temp_dir allocation leaks if support_can_chroot returns false.

13 days agoLinux: Block signals around _Fork (bug 32215)
Florian Weimer [Sat, 28 Sep 2024 07:44:25 +0000 (09:44 +0200)]
Linux: Block signals around _Fork (bug 32215)

This hides the inconsistent TCB state (missing robust mutex list) from
signal handlers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agoUpdate to Unicode 16.0.0 [BZ #32168]
Mike FABIAN [Thu, 12 Sep 2024 13:02:55 +0000 (15:02 +0200)]
Update to Unicode 16.0.0 [BZ #32168]

Unicode 16.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 16.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Changes in CHARMAP and WIDTH:

    Total added characters in newly generated CHARMAP: 5185
    Total removed characters in newly generated WIDTH: 1
    Total added characters in newly generated WIDTH: 170

The removed character from WIDTH is U+1171E AHOM CONSONANT SIGN MEDIAL RA.
It changed like this:

UnicodeData.txt 15.1.0: 1171E;AHOM CONSONANT SIGN MEDIAL RA;Mn;0;NSM;;;;;N;;;;;
UnicodeData.txt 16.0.0: 1171E;AHOM CONSONANT SIGN MEDIAL RA;Mc;0;L;;;;;N;;;;;

EastAsianWidth.txt 15.1.0: 1171D..1171F   ; N  # Mn     [3] AHOM CONSONANT SIGN MEDIAL LA..AHOM CONSONANT SIGN MEDIAL LIGATING RA
EastAsianWidth.txt 16.0.0: 1171E          ; N  # Mc         AHOM CONSONANT SIGN MEDIAL RA

I.e it changed from Mn (Mark Nonspacing) to Mc (Mark Spacing
combining). So it should now have width 1 instead of 0, therefore it
is OK that it was removed from WIDTH, characters not in WIDTH get
width 1 by default.

Nothing suspicious when browsing the list of the 170 added characters.

Changes in ctype:

    alpha: Added 4452 characters in new ctype which were not in old ctype
    combining: Added 51 characters in new ctype which were not in old ctype
    combining_level3: Added 43 characters in new ctype which were not in old ctype
    graph: Added 5185 characters in new ctype which were not in old ctype
    lower: Added 25 characters in new ctype which were not in old ctype
    print: Added 5185 characters in new ctype which were not in old ctype
    punct: Missing 33 characters of old ctype in new ctype
    punct: Added 766 characters in new ctype which were not in old ctype
    tolower: Added 27 characters in new ctype which were not in old ctype
    totitle: Added 27 characters in new ctype which were not in old ctype
    toupper: Added 27 characters in new ctype which were not in old ctype
    upper: Added 27 characters in new ctype which were not in old ctype

Nothing suspicous in the additions.

About the 33 characters removed from `punct`:

U+0363 - U+036F are identical in UnicodeData.txt. Difference in DerivedCoreProperties.txt:

DerivedCoreProperties.txt 15.1.0: not there.
DerivedCoreProperties.txt 16.0.0: 0363..036F    ; Alphabetic # Mn  [13] COMBINING LATIN SMALL LETTER A..COMBINING LATIN SMALL LETTER X

So that’s the reason why they are added to `alpha` and removed from `punct`.

Same for U+1DD3 - U+1DE6, they are identical in UnicodeData.txt but there is a difference in DerivedCoreProperties.txt:

DerivedCoreProperties.txt 15.1.0: 1DE7..1DF4    ; Alphabetic # Mn  [14] COMBINING LATIN SMALL LETTER ALPHA..COMBINING LATIN SMALL LETTER U WITH DIAERESIS
DerivedCoreProperties.txt 16.0.0: 1DD3..1DF4    ; Alphabetic # Mn  [34] COMBINING LATIN SMALL LETTER FLATTENED OPEN A ABOVE..COMBINING LATIN SMALL LETTER U WITH DIAERESIS

So they became `Alphabetic` and were thus added to `alpha` and removed from `punct`.

Resolves: BZ #32168

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agomanual: Document that feof and ferror are mutually exclusive
Florian Weimer [Fri, 27 Sep 2024 09:41:12 +0000 (11:41 +0200)]
manual: Document that feof and ferror are mutually exclusive

This is not completely clear from the C standard (although there
is footnote number 289 in C11), but I assume that our implementation
works this way.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agostdio-common: Add new test for fdopen
Sergey Kolosov [Wed, 25 Sep 2024 13:51:23 +0000 (15:51 +0200)]
stdio-common: Add new test for fdopen

This commit adds fdopen test with all modes.
Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agoFix missing randomness in __gen_tempname (bug 32214)
Andreas Schwab [Wed, 25 Sep 2024 09:49:30 +0000 (11:49 +0200)]
Fix missing randomness in __gen_tempname (bug 32214)

Make sure to update the random value also if getrandom fails.

Fixes: 686d542025 ("posix: Sync tempname with gnulib")
2 weeks agoarc: Cleanup arcbe
Pavel Kozlov [Fri, 20 Sep 2024 17:58:52 +0000 (18:58 +0100)]
arc: Cleanup arcbe

Remove the mention of arcbe ABI to avoid any mislead.
ARC big endian ABI is no longer supported.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoarc: Remove HAVE_ARC_BE macro and disable big-endian port
Florian Weimer [Wed, 25 Sep 2024 09:24:54 +0000 (11:24 +0200)]
arc: Remove HAVE_ARC_BE macro and disable big-endian port

It is no longer needed, now that ARC is always little endian.

2 weeks agoscripts: Remove arceb-linux-gnu from build-many-glibcs.py
Florian Weimer [Wed, 25 Sep 2024 09:24:54 +0000 (11:24 +0200)]
scripts: Remove arceb-linux-gnu from build-many-glibcs.py

This was discussed on the hallway track at GNU Tools Cauldron
2024.  There are concerns about stability of the big-endian
GCC backend, and Linux removed support for the only big-endian
ARC platform in commit dd7c7ab01a04d645b7e7baa8530bfd81e31a2202
("ARC: [plat-eznps]: Drop support for EZChip NPS platform").

2 weeks agoLoongArch: Undef __NR_fstat and __NR_newfstatat.
caiyinyu [Tue, 24 Sep 2024 03:09:32 +0000 (11:09 +0800)]
LoongArch: Undef __NR_fstat and __NR_newfstatat.

In Linux 6.11, fstat and newfstatat are added back. To avoid the messy
usage of the fstat, newfstatat, and statx system calls, we will continue
using statx only in glibc, maintaining consistency with previous versions of
the LoongArch-specific glibc implementation.

Signed-off-by: caiyinyu <caiyinyu@loongson.cn>
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
Suggested-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoAdd tests of fread
Joseph Myers [Tue, 24 Sep 2024 14:06:22 +0000 (14:06 +0000)]
Add tests of fread

There seem to be no glibc tests specifically for the fread function.
Add basic tests of that function.

Tested for x86_64.

2 weeks agonptl: Prefer setresuid32 in tst-setuid2
Florian Weimer [Tue, 24 Sep 2024 11:48:11 +0000 (13:48 +0200)]
nptl: Prefer setresuid32 in tst-setuid2

Use the setresuid32 system call if it is available, prefering
it over setresuid.  If both system calls exist, setresuid
is the 16-bit variant.  This fixes a build failure on
sparcv9-linux-gnu.

2 weeks agoelf: Move __rtld_malloc_init_stubs call into _dl_start_final
Florian Weimer [Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)]
elf: Move __rtld_malloc_init_stubs call into _dl_start_final

Calling an extern function in a different translation unit before
self-relocation is brittle.  The compiler may load the address
at an earlier point in _dl_start, before self-relocation.  In
_dl_start_final, the call is behind a compiler barrier, so this
cannot happen.

2 weeks agoelf: Eliminate alloca in open_verify
Florian Weimer [Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)]
elf: Eliminate alloca in open_verify

With the two-stage approach for exception handling, the name can
be freed after it has been copied into the exception, but before
it is raised.

2 weeks agoelf: Remove version assert in check_match in elf/dl-lookup.c
Florian Weimer [Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)]
elf: Remove version assert in check_match in elf/dl-lookup.c

This case is detected early in the elf/dl-version.c consistency
checks.  (These checks could be disabled in the future to allow
the removal of symbol versioning from objects.)

Commit f0b2132b35 ("ld.so: Support moving versioned symbols between
sonames [BZ #24741]) removed another call to _dl_name_match_p.  The
_dl_check_caller function no longer exists, and the remaining calls
to _dl_name_match_p happen under the loader lock.  This means that
atomic accesses are no longer required for the l_libname list.  This
supersedes commit 395be7c218 ("elf: Fix data race in _dl_name_match_p
[BZ #21349]").

2 weeks agoelf: In rtld_setup_main_map, assume ld.so has a DYNAMIC segment
Florian Weimer [Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)]
elf: In rtld_setup_main_map, assume ld.so has a DYNAMIC segment

The way we build ld.so, it always has a dynamic segment, so checking for
its absence is unnecessary.

2 weeks agomisc: Enable internal use of memory protection keys
Florian Weimer [Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)]
misc: Enable internal use of memory protection keys

This adds the necessary hidden prototypes.

2 weeks agomisc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library)
Florian Weimer [Tue, 24 Sep 2024 11:05:48 +0000 (13:05 +0200)]
misc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library)

The barrier functions require this on Hurd.

2 weeks agoiconv: Use $(run-program-prefix) for running iconv (bug 32197)
Florian Weimer [Tue, 24 Sep 2024 08:41:35 +0000 (10:41 +0200)]
iconv: Use $(run-program-prefix) for running iconv (bug 32197)

With --enable-hardcoded-path-in-tests, $(test-program-prefix)
does not redirect to the built glibc, but we need to run
iconv (the program) against the built glibc even with
--enable-hardcoded-path-in-tests, as it is using the ABI
path for the dynamic linker (as an installed program).
Use $(run-program-prefix) instead.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoAArch64: Simplify rounding-multiply pattern in several AdvSIMD routines
Joe Ramsay [Mon, 23 Sep 2024 14:33:31 +0000 (15:33 +0100)]
AArch64: Simplify rounding-multiply pattern in several AdvSIMD routines

This operation can be simplified to use simpler multiply-round-convert
sequence, which uses fewer instructions and constants.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoAArch64: Improve codegen in users of ADVSIMD expm1f helper
Joe Ramsay [Mon, 23 Sep 2024 14:32:53 +0000 (15:32 +0100)]
AArch64: Improve codegen in users of ADVSIMD expm1f helper

Rearrange operations so MOV is not necessary in reduction or around
the special-case handler.  Reduce memory access by using more indexed
MLAs in polynomial.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoAArch64: Improve codegen in users of AdvSIMD log1pf helper
Joe Ramsay [Mon, 23 Sep 2024 14:32:14 +0000 (15:32 +0100)]
AArch64: Improve codegen in users of AdvSIMD log1pf helper

log1pf is quite register-intensive - use fewer registers for the
polynomial, and make various changes to shorten dependency chains in
parent routines.  There is now no spilling with GCC 14.  Accuracy moves
around a little - comments adjusted accordingly but does not require
regen-ulps.

Use the helper in log1pf as well, instead of having separate
implementations.  The more accurate polynomial means special-casing can
be simplified, and the shorter dependency chain avoids the usual dance
around v0, which is otherwise difficult.

There is a small duplication of vectors containing 1.0f (or 0x3f800000) -
GCC is not currently able to efficiently handle values which fit in FMOV
but not MOVI, and are reinterpreted to integer.  There may be potential
for more optimisation if this is fixed.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoAArch64: Improve codegen in SVE F32 logs
Joe Ramsay [Mon, 23 Sep 2024 14:30:20 +0000 (15:30 +0100)]
AArch64: Improve codegen in SVE F32 logs

Reduce MOVPRFXs by using unpredicated (non-destructive) instructions
where possible.  Similar to the recent change to AdvSIMD F32 logs,
adjust special-case arguments and bounds to allow for more optimal
register usage.  For all 3 routines one MOVPRFX remains in the
reduction, which cannot be avoided as immediate AND and ASR are both
destructive.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoAArch64: Improve codegen in SVE expf & related routines
Joe Ramsay [Mon, 23 Sep 2024 14:26:12 +0000 (15:26 +0100)]
AArch64: Improve codegen in SVE expf & related routines

Reduce MOV and MOVPRFX by improving special-case handling.  Use inline
helper to duplicate the entire computation between the special- and
non-special case branches, removing the contention for z0 between x
and the return value.

Also rearrange some MLAs and MLSs - by making the multiplicand the
destination we can avoid a MOVPRFX in several cases.  Also change which
constants go in the vector used for lanewise ops - the last lane is no
longer wasted.

Spotted that shift was incorrect in exp2f and exp10f, w.r.t. to the
comment that explains it.  Fixed - worst-case ULP for exp2f moves
around but it doesn't change significantly for either routine.

Worst-case error for coshf increases due to passing x to exp rather
than abs(x) - updated the comment, but does not require regen-ulps.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoLinux: readdir64_r should not skip d_ino == 0 entries (bug 32126)
Florian Weimer [Sat, 21 Sep 2024 17:32:34 +0000 (19:32 +0200)]
Linux: readdir64_r should not skip d_ino == 0 entries (bug 32126)

This is the same bug as bug 12165, but for readdir_r.  The
regression test covers both bug 12165 and bug 32126.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agodirent: Add tst-rewinddir
Florian Weimer [Sat, 21 Sep 2024 17:32:34 +0000 (19:32 +0200)]
dirent: Add tst-rewinddir

It verifies that rewinddir allows restarting the directory
iteration.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agodirent: Add tst-readdir-long
Florian Weimer [Sat, 21 Sep 2024 17:32:34 +0000 (19:32 +0200)]
dirent: Add tst-readdir-long

It tests long names and ENAMETOOLONG handling, specifically
for readdir_r.  This is a regression test for bug 14699,
bug 32124, and bug 32128.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agoLinux: Use readdir64_r for compat __old_readdir64_r (bug 32128)
Florian Weimer [Sat, 21 Sep 2024 17:32:34 +0000 (19:32 +0200)]
Linux: Use readdir64_r for compat __old_readdir64_r (bug 32128)

It is not necessary to do the conversion at the getdents64
layer for readdir64_r.  Doing it piecewise for readdir64
is slightly simpler and allows deleting __old_getdents64.

This fixes bug 32128 because readdir64_r handles the length
check correctly.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agodirent: Add tst-closedir-leaks
Florian Weimer [Sat, 21 Sep 2024 17:32:34 +0000 (19:32 +0200)]
dirent: Add tst-closedir-leaks

It verfies that closedir deallocates memory and closes
file descriptors.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agosupport: Add valgrind instructions to <support/fuse.h>
Florian Weimer [Sat, 21 Sep 2024 17:29:13 +0000 (19:29 +0200)]
support: Add valgrind instructions to <support/fuse.h>

Replacing an outdated comment (namespace setup is now handled by
support_fuse_init).

2 weeks agosupport: Fix memory leaks in FUSE tests
Florian Weimer [Sat, 21 Sep 2024 17:25:35 +0000 (19:25 +0200)]
support: Fix memory leaks in FUSE tests

The internal read buffer (used by all FUSE tests) was not freed.
The support/tst-support_fuse test missed a deallocation.

2 weeks agomisc: FUSE-based tests for mkstemp
Florian Weimer [Sat, 21 Sep 2024 17:25:35 +0000 (19:25 +0200)]
misc: FUSE-based tests for mkstemp

The tests check that O_EXCL is used properly, that 0600 is used
as the mode, that the characters used are as expected, and that
the distribution of names generated is reasonably random.

The tests run very slowly on some kernel versions, so make them
xtests.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 weeks agoAdd freopen special-case tests: chroot, EFBIG, stdin/stdout/stderr
Joseph Myers [Fri, 20 Sep 2024 23:26:31 +0000 (23:26 +0000)]
Add freopen special-case tests: chroot, EFBIG, stdin/stdout/stderr

Add tests of special cases for freopen that were omitted from the more
general tests of different modes and similar issues.  The special
cases in the three tests here are logically unconnected, it was simply
convenient to put these tests in one patch.

* Test freopen with a NULL path to the new file, in a chroot.  Rather
  than asserting that this fails (logically, failure in this case is
  an implementation detail; it's not required for freopen to rely on
  /proc), verify that either it fails (without memory leaks) or that
  it succeeds and behaves as expected on success.  There is no check
  for file descriptor leaks because the machinery for that also
  depends on /proc, so can't be used in a chroot.

* Test that freopen and freopen64 are genuinely different in
  configurations with 32-bit off_t by checking for an EFBIG trying to
  write past 2GB in a file opened with freopen in such a configuration
  but no error with 64-bit off_t or when opening with freopen64.

* Test freopen of stdin, stdout and stderr.

Tested for x86_64 and x86.

2 weeks agoMake tst-strtod-underflow type-generic
Joseph Myers [Fri, 20 Sep 2024 23:25:32 +0000 (23:25 +0000)]
Make tst-strtod-underflow type-generic

The test tst-strtod-underflow covers various edge cases close to the
underflow threshold for strtod (especially cases where underflow on
architectures with after-rounding tininess detection depends on the
rounding mode).  Make it use the type-generic machinery, with
corresponding test inputs for each supported floating-point format, so
that other functions in the strtod family are tested for underflow
edge cases as well.

Tested for x86_64.

2 weeks agoAdd tests of more strtod special cases
Joseph Myers [Fri, 20 Sep 2024 23:24:45 +0000 (23:24 +0000)]
Add tests of more strtod special cases

There is very little test coverage of inputs to strtod-family
functions that don't contain anything that can be parsed as a number
(one test of ".y" in tst-strtod2), and none that I can see of skipping
initial whitespace.  Add some tests of these things to tst-strtod2.

Tested for x86_64.

2 weeks agoAdd more tests of strtod end pointer
Joseph Myers [Fri, 20 Sep 2024 23:24:02 +0000 (23:24 +0000)]
Add more tests of strtod end pointer

Although there are some tests in tst-strtod2 and tst-strtod3 for the
end pointer provided by strtod when it doesn't parse the whole string,
they aren't very thorough.  Add tests of more such cases to
tst-strtod2.

Tested for x86_64.

2 weeks agoMake tst-strtod2 and tst-strtod5 type-generic
Joseph Myers [Fri, 20 Sep 2024 23:23:13 +0000 (23:23 +0000)]
Make tst-strtod2 and tst-strtod5 type-generic

Some of the strtod tests use type-generic machinery in tst-strtod.h to
test the strto* functions for all floating types, while others only
test double even when the tests are in fact meaningful for all
floating types.

Convert tst-strtod2 and tst-strtod5 to use the type-generic machinery
so they test all floating types.  I haven't tried to convert them to
use newer test interfaces in other ways, just made the changes
necessary to use the type-generic machinery.

Tested for x86_64.

2 weeks agoImplement run-built-tests=no for make xcheck, always build xtests
Florian Weimer [Thu, 19 Sep 2024 13:40:05 +0000 (15:40 +0200)]
Implement run-built-tests=no for make xcheck, always build xtests

Previously, the second occurrence of the xtests target
expected all xtests to run (as the result of specifying
$(xtests)), but these tests have not been run due to
the the first xtests target is set up for run-built-tests=no:
it only runs tests in $(xtests-special).  Consequently,
xtests are reported as UNSUPPORTED with “make xcheck
run-built-tests=no”.  The xtests were not built, either.

After this change always, xtests are built regardless
of the $(run-built-tests) variable (except for xtests listed
in $(tests-unsupported)).  To fix the UNSUPPORTED issue,
introduce xtests-expected and use that manage test
expectations in the second xtests target.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agoTest that errno is set to 0 at program startup
Aaron Merey [Thu, 19 Sep 2024 15:11:39 +0000 (11:11 -0400)]
Test that errno is set to 0 at program startup

Add new testcase elf/tst-startup-errno.c which tests that errno is set
to 0 at first ELF constructor execution and at the start of the
program's main function.

Tested for x86_64

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agoAdd another test for fclose on an unopened file
Aaron Merey [Thu, 19 Sep 2024 13:53:23 +0000 (09:53 -0400)]
Add another test for fclose on an unopened file

Add new file libio/tst-fclose-unopened2.c that tests whether fclose on an
unopened file returns EOF.

This test differs from tst-fclose-unopened.c by ensuring the file's buffer
is allocated prior to double-fclose.  A comment in tst-fclose-unopened.c
now clarifies that it is testing a file with an unallocated buffer.

Calling fclose on unopened files normally causes a use-after-free bug,
however the standard streams are an exception since they are not
deallocated by fclose.

Tested for x86_64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agoiconv: Input buffering for the iconv program (bug 6050)
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Input buffering for the iconv program (bug 6050)

Do not read the entire input file into memory.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoiconv: Multiple - on command line should not fail (bug 32050)
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Multiple - on command line should not fail (bug 32050)

Usually, the second and subsequent - return EOF immediately
and do not contribute to the output, but this is not an error.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoiconv: Support in-place conversions (bug 10460, bug 32033)
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Support in-place conversions (bug 10460, bug 32033)

Check if any of the input files overlaps with the output file, and use
a temporary file in this case, so that the input is no clobbered
before it is read.  This fixes bug 10460.  It allows to use iconv
more easily as a functional replacement for GNU recode.

The updated output buffer management truncates the output file
if there is no input, fixing bug 32033.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoiconv: Preserve iconv -c error exit on invalid inputs (bug 32046)
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Preserve iconv -c error exit on invalid inputs (bug 32046)

In several converters, a __GCONV_ILLEGAL_INPUT result gets overwritten
with __GCONV_FULL_OUTPUT.  As a result, iconv (the function) returns
E2BIG instead of EILSEQ.  The iconv program does not see the original
EILSEQ failure, does not recognize the invalid input, and may
incorrectly exit successfully.

To address this, a new __flags bit is used to indicate a sticky input
error state.  All __GCONV_ILLEGAL_INPUT results are replaced with a
function call that sets this new __GCONV_ENCOUNTERED_ILLEGAL_INPUT and
returns __GCONV_ILLEGAL_INPUT.  The iconv program checks for
__GCONV_ENCOUNTERED_ILLEGAL_INPUT and overrides the exit status.

The converter changes introducing __gconv_mark_illegal_input are
mostly mechanical, except for the res variable initialization in
iconvdata/iso-2022-jp.c: this error gets overwritten with __GCONV_OK
and other results in the following code.  If res ==
__GCONV_ILLEGAL_INPUT afterwards, STANDARD_TO_LOOP_ERR_HANDLER below
will handle it.

The __gconv_mark_illegal_input changes do not alter the errno value
set by the iconv function.  This is simpler to implement than
reviewing each __GCONV_FULL_OUTPUT result and adjust it not to
override a previous __GCONV_ILLEGAL_INPUT result.  Doing it that way
would also change some E2BIG errors in to EILSEQ errors, so it had to
be done conditionally (under a flag set by the iconv program only), to
avoid confusing buffer management in other applications.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agomanual: __is_last is no longer part of iconv internals
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
manual: __is_last is no longer part of iconv internals

The __is_last field was replaced with a bitmask in
commit 85830c4c4688b30d3d76111aa9a26745c7b141d6 in 2000,
and multiple bits are in use today.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoiconv: Do not use mmap in iconv (the program) (bug 17703)
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Do not use mmap in iconv (the program) (bug 17703)

On current systems, very large files are needed before
mmap becomes beneficial.  Simplify the implementation.

This exposed that inptr was not initialized correctly in
process_fd.  Handling multiple input files resulted in
EFAULT in read because a null pointer was passed.  This
could be observed previously if an input file was not
mappable and was reported as bug 17703.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoiconv: Base tests for buffer management
Florian Weimer [Fri, 20 Sep 2024 11:10:54 +0000 (13:10 +0200)]
iconv: Base tests for buffer management

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoAArch64: Add vector logp1 alias for log1p
Joe Ramsay [Thu, 19 Sep 2024 16:34:02 +0000 (17:34 +0100)]
AArch64: Add vector logp1 alias for log1p

This enables vectorisation of C23 logp1, which is an alias for log1p.
There are no new tests or ulp entries because the new symbols are simply
aliases.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 weeks agohurd: Avoid file_check_access () RPC for access (F_OK)
Sergey Bugaev [Thu, 19 Sep 2024 10:14:39 +0000 (13:14 +0300)]
hurd: Avoid file_check_access () RPC for access (F_OK)

A common use case of access () / faccessat () is checking for file
existence, not any specific access permissions.  In that case, we can
avoid doing the file_check_access () RPC; whether the given path had
been successfully resolved to a file is all we need to know to answer.

This is prompted by GLib switching to use faccessat (F_OK) to implement
g_file_query_exists () for local files.
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4272

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240919101439.179663-1-bugaevc@gmail.com>

3 weeks agotst: Extend cross-test-ssh.sh to support passing glibc tunables
Yury Khrustalev [Mon, 9 Sep 2024 08:29:14 +0000 (09:29 +0100)]
tst: Extend cross-test-ssh.sh to support passing glibc tunables

This patch adds new flag --glibctunables to the cross-test-ssh.sh script
to pass Glibc tunables to the system on which tests are executed.

The value to pass can be also provided via the GLIBC_TUNABLES environment
variable.

This works similar to the TIMEOUTFACTOR variable.

Sometimes it is useful to cross test glibc with some non-default tunable,
and a global environment variable is the easiest way to inject some
tunable value into most tests. With this patch using cross-test-ssh.sh
script becomes very similar to running a test natively on the local host
when using non-default tunable is important.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 weeks agosupport: Fix Hurd build of tst-support_readdir
Florian Weimer [Thu, 12 Sep 2024 16:26:04 +0000 (18:26 +0200)]
support: Fix Hurd build of tst-support_readdir

Check for the availability of the d_off member at compile time, not
run time.

Fixes commit 1251e9ea49fba9f53bbf4f290f3db90c01931fa7
("support: Add <support/readdir.h>").

4 weeks agosupport: Add <support/readdir.h>
Florian Weimer [Thu, 12 Sep 2024 07:40:25 +0000 (09:40 +0200)]
support: Add <support/readdir.h>

It allows to read directories using the six readdir variants
without writing type-specific code or using skeleton files
that are compiled four times.

The readdir_r subtest for support_readdir_expect_error revealed
bug 32124.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 weeks agoLinux: Add missing scheduler constants to <sched.h>
Florian Weimer [Wed, 11 Sep 2024 08:05:08 +0000 (10:05 +0200)]
Linux: Add missing scheduler constants to <sched.h>

And add a test, misc/tst-sched-consts, that checks
consistency with <sched.h>.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agoLinux: Add the sched_setattr and sched_getattr functions
Florian Weimer [Wed, 11 Sep 2024 08:05:08 +0000 (10:05 +0200)]
Linux: Add the sched_setattr and sched_getattr functions

And struct sched_attr.

In sysdeps/unix/sysv/linux/bits/sched.h, the hack that defines
sched_param around the inclusion of <linux/sched/types.h> is quite
ugly, but the definition of struct sched_param has already been
dropped by the kernel, so there is nothing else we can do and maintain
compatibility of <sched.h> with a wide range of kernel header
versions.  (An alternative would involve introducing a separate header
for this functionality, but this seems unnecessary.)

The existing sched_* functions that change scheduler parameters
are already incompatible with PTHREAD_PRIO_PROTECT mutexes, so
there is no harm in adding more functionality in this area.

The documentation mostly defers to the Linux manual pages.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agomanual: Extract the @manpageurl{func,sec} macro
Florian Weimer [Wed, 11 Sep 2024 08:05:08 +0000 (10:05 +0200)]
manual: Extract the @manpageurl{func,sec} macro

From the existing @manpagefunctionstub{func,sec} macro,
so that URLs can be included in the manual without the
stub text.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agoAArch64: Remove memset-reg.h
Wilco Dijkstra [Tue, 10 Sep 2024 13:17:05 +0000 (14:17 +0100)]
AArch64: Remove memset-reg.h

Remove memset-reg.h by moving register definitions into the memset
implementations.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agodebug: Fix read error handling in pcprofiledump
Florian Weimer [Tue, 10 Sep 2024 10:40:27 +0000 (12:40 +0200)]
debug: Fix read error handling in pcprofiledump

The reading loops did not check for read failures.  Addresses
a static analysis report.

Manually tested by compiling a program with the GCC's
-finstrument-functions option, running it with
“LD_PRELOAD=debug/libpcprofile.so PCPROFILE_OUTPUT=output-file”,
and reviewing the output of “debug/pcprofiledump output-file”.

4 weeks agoelf: Fix tst-dlopen-tlsreinit1.out test dependency
Florian Weimer [Mon, 9 Sep 2024 19:10:23 +0000 (21:10 +0200)]
elf: Fix tst-dlopen-tlsreinit1.out test dependency

Fixes commit 5097cd344fd243fb8deb6dec96e8073753f962f9
("elf: Avoid re-initializing already allocated TLS in dlopen
(bug 31717)").

Reported-by: Patsy Griffin <patsy@redhat.com>
Reviewed-by: Patsy Griffin <patsy@redhat.com>
4 weeks agoAdd a new fwrite test for memory streams
Tulio Magno Quites Machado Filho [Thu, 29 Aug 2024 17:12:41 +0000 (14:12 -0300)]
Add a new fwrite test for memory streams

Ensure that fwrite() behaves correctly when using memory streams.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agoAdd a new fwrite test for read-only streams
Tulio Magno Quites Machado Filho [Thu, 5 Sep 2024 18:34:29 +0000 (15:34 -0300)]
Add a new fwrite test for read-only streams

Ensure that fwrite() behaves correctly even when the stream is
read-only.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 weeks agoAArch64: Optimize memset
Wilco Dijkstra [Mon, 9 Sep 2024 14:26:47 +0000 (15:26 +0100)]
AArch64: Optimize memset

Improve small memsets by avoiding branches and use overlapping stores.
Use DC ZVA for copies over 128 bytes.  Remove unnecessary code for ZVA sizes
other than 64 and 128.  Performance of random memset benchmark improves by 24%
on Neoverse N1.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agohppa: Update libm-test-ulps
John David Anglin [Mon, 9 Sep 2024 13:57:42 +0000 (09:57 -0400)]
hppa: Update libm-test-ulps

4 weeks agoaarch64: Avoid redundant MOVs in AdvSIMD F32 logs
Joe Ramsay [Mon, 9 Sep 2024 12:00:01 +0000 (13:00 +0100)]
aarch64: Avoid redundant MOVs in AdvSIMD F32 logs

Since the last operation is destructive, the first argument to the FMA
also has to be the first argument to the special-case in order to
avoid unnecessary MOVs. Reorder arguments and adjust special-case
bounds to facilitate this.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agoio: Add FUSE-based test for fchmod
Florian Weimer [Thu, 22 Aug 2024 09:02:51 +0000 (11:02 +0200)]
io: Add FUSE-based test for fchmod

Test all mode arguments, and that extra bits are ignored
as required by POSIX.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 weeks agoio: Add tst-lstat-nofollow, tst-lstat-nofollow-time64
Florian Weimer [Thu, 29 Aug 2024 09:06:08 +0000 (11:06 +0200)]
io: Add tst-lstat-nofollow, tst-lstat-nofollow-time64

They verify that lstat, lstat64 do not follow symbolic links.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 weeks agoDocument limitations on streams passed to freopen
Joseph Myers [Fri, 6 Sep 2024 20:38:23 +0000 (20:38 +0000)]
Document limitations on streams passed to freopen

As recently discussed, document that freopen does not work with
streams opened with functions such as popen, fmemopen, open_memstream
or fopencookie.  I've filed
<https://austingroupbugs.net/view.php?id=1855> to clarify this issue
in POSIX.

Tested with "make info" and "make html".

5 weeks agostdlib: Do not use GLIBC_PRIVATE ABI for errno in libc_nonshared.a
Florian Weimer [Fri, 6 Sep 2024 12:07:00 +0000 (14:07 +0200)]
stdlib: Do not use GLIBC_PRIVATE ABI for errno in libc_nonshared.a

Using TLS directly introduces a GLIBC_PRIVATE ABI dependency
into libc_nonshared.a, and thus indirectly into applications.
Adding the !defined LIBC_NONSHARED condition deactivates direct
TLS access, and libc_nonshared.a code switches to using
__errno_location, like application code.

Currently, this has no effect because there is no code in
libc_nonshared.a that accesses errno.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 weeks agomanual: Safety annotations for clock_gettime, clock_getres
Florian Weimer [Fri, 6 Sep 2024 12:07:00 +0000 (14:07 +0200)]
manual: Safety annotations for clock_gettime, clock_getres

The annotations are preliminary, for consistency with existing
annotations on gettimeofday etc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 weeks agoLoongArch: Fix macro redefined warning in tls-desc.S
mengqinggang [Mon, 2 Sep 2024 01:51:04 +0000 (09:51 +0800)]
LoongArch: Fix macro redefined warning in tls-desc.S

Undef macro to avoid redefined warning.

5 weeks agotimezone: sync to TZDB 2024b
Adhemerval Zanella [Thu, 5 Sep 2024 12:33:09 +0000 (09:33 -0300)]
timezone: sync to TZDB 2024b

Sync tzselect, zdump, zic to TZDB 2024b. This patch incorporates the
following TZDB source code changes:

6903dde3 Release 2024b
812aff32 Improve historical transitions in Mexico 1921-1997
52662566 Adjust to mailing list software change
7748036b Mention Internet RFC 9557
339e81d1 Mention Levine’s proposal to replace leap seconds
b4e6ad2d No leap second on 2024-12-31
7eb5bf88 Asia/Choibalsan is now an alias for Asia/Ulaanbaatar
43450cbf Improve historical data for Portugal and former possessions.
13d7348b Typo and validation fixes.
3c39cde8 Fix typo for “removed” in a comment
03fd9e45 More documentation updates for POSIX.1-2024
eb3bcceb POSIX.1-2014 is now published
913b0410 tzselect: support POSIX.1-2024 offset range
b5318b55 Document POSIX.1-2024 better
837609b7 Fix typo when making .txt man pages
d56ae6ee SUPPORT_C89 now defaults to 1, not 0
b1fe113d Port ! to Solaris make
8f1fd321 Avoid crash in Solaris 10 /usr/xpg4/bin/make
e0fcfdd6 Use ‘export VAR=VAL’ syntax
eba43166 Avoid an awk invocation via $'...'
36479a80 Avoid some subshells in tzselect
7f6cf054 * tzselect.ksh: Assume POSIX.2 awk.
a1cf1daf * tzselect.ksh: Assume POSIX.2 $PWD.
a9b8e536 Assume POSIX.2 command substitution
eaa4ef16 Avoid subshells when possible
9dac9eb7 Prefer $PWD to $(pwd) in Makefile
fada6a4c Prefer $(CMD) to `CMD` in Makefile
3e871b9a Assume POSIX.2 and eschew ‘expr’
c5d67805 difftime isn’t pure either
5857c056 * CONTRIBUTING: Document build assumptions.
6822cc82 ‘make check’ no longer depends on curl+Internet
cc6eb255 Document GCC bug 114833 and workaround
bcbc86bf Scale back on function attribute use
c0789e46 C23 [[reproducible]] and [[unsequenced]] fixups
bbd88154 More updates to GCC_DEBUG_FLAGS for GCC 14
1a35b7c8 Spelling fixes
f71085f2 POSIX.1-2024 removes asctime_r, ctime_r
70856f8e Adjust to refactored location of ctime, ctime_r
aacd151d Update GCC_DEBUG_FLAGS for GCC 14
967dcf3b Sub-second history for Maputo and Zurich
782d0826 Make EET, MET and WET links
a0b09c02 Mark CET, CST6CDT etc. as obsolescent
db7fb40d Document SMPTE timecodes and rolling leaps
97232e18 Don’t be so sure about leap seconds going away
5b6a74fb Update some URLs
a75a6251 * zic.8: Tweak for consistency.
1e75b31f Document what %s means before any rule applies
00c96cbb Conform to RFC 8536 section 3.2 for default type
3e944959 Document problems with stripped-down TZif readers
20fc91cf Shanks is likely wrong about Maputo switch to CAT
d99589b6 * zic.8: Add missing tab character.
94e6b3b0 Switch to %z in main dataform
2cd57b93 Treat W-Eur like Port when reguarding
ad6f6d94 Check that main.zi agrees with sources
a43b030f .gitignore: Add .pdf, .ps, .s. Remove obsolete ‘yearistype’.
253ca020 * theory.html: ‘CLT’ → ‘LTC’ (per Michael H Deckers)
a3dee8c8 * NEWS: ‘how’ → ‘now’ (thanks to Paul Goyette).
ea6341c5 * theory.html: Mention NASA and CLT (per Arthur David Olson).
0dcebe37 America/Scoresbysund matches America/Nuuk from now on
b1e07fb0 Update Vzic link (thanks to Allen Winter)
a4b05030 Fix wday/mday typo in previous patch
732a4803 Document how to detect mktime failure reliably
a64067e9 ziguard.awk: generalize for proposed Portugal patch
59c861fd Line up zdump examples
66c106c9 tzfile.5: srcfix
e5553001 Fix .RS/.RE problem in tzfile.5
d647eb01 Add Doctorow book
59d4a1ba Asia/Almaty matches Asia/Tashkent from now on
d4d3c3ba * asia: Update Philippine URLs (thanks to Guy Harris).
9fc11a27 Port unlikely overflow check to C23
b52a2969 Fix 2023d NEWS typo
e48c5b53 Cite "The NTP Leap Second File"
b1dc2122 Update Israel tz-link
6cf4e912 Extrapolate less from the 2022 CGPM resolution.

It fixes glibc build with gcc master [1].

Checked on x86_64-linux-gnu and on i686-linux-gnu.

[1] https://sourceware.org/pipermail/libc-alpha/2024-September/159571.html
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
5 weeks agoi386: Update ulps
Florian Weimer [Thu, 5 Sep 2024 20:25:55 +0000 (22:25 +0200)]
i386: Update ulps

As seen on an AMD Ryzen 9 7950X CPU when building with GCC 14
with SSE2 math.

5 weeks agoFix freopen handling of ,ccs= (bug 23675)
Joseph Myers [Thu, 5 Sep 2024 20:08:10 +0000 (20:08 +0000)]
Fix freopen handling of ,ccs= (bug 23675)

As reported in bug 23675 and shown up in the recently added tests of
different cases of freopen (relevant part of the test currently
conditioned under #if 0 to avoid a failure resulting from this bug),
freopen wrongly forces the stream to unoriented even when a mode with
,ccs= is specified, though such a mode is supposed to result in a
wide-oriented stream.  Move the clearing of _mode to before the actual
reopening occurs, so that the main fopen implementation can leave a
wide-oriented stream in the ,ccs= case.

Tested for x86_64.

5 weeks agopowerpc64le: Build new strtod tests with long double ABI flags (bug 32145)
Florian Weimer [Thu, 5 Sep 2024 19:18:23 +0000 (21:18 +0200)]
powerpc64le: Build new strtod tests with long double ABI flags (bug 32145)

This fixes several test failures:

=====FAIL: stdlib/tst-strtod1i.out=====
Locale tests
all OK
Locale tests
all OK
Locale tests
strtold("1,5") returns -6,38643e+367 and not 1,5
strtold("1.5") returns 1,5 and not 1
strtold("1.500") returns 1 and not 1500
strtold("36.893.488.147.419.103.232") returns 1500 and not 3,68935e+19
Locale tests
all OK

=====FAIL: stdlib/tst-strtod3.out=====
0: got wrong results -2.5937e+4826, expected 0

=====FAIL: stdlib/tst-strtod4.out=====
0: got wrong results -6,38643e+367, expected 0
1: got wrong results 0, expected 1e+06
2: got wrong results 1e+06, expected 10

=====FAIL: stdlib/tst-strtod5i.out=====
0: got wrong results -6,38643e+367, expected 0
2: got wrong results 0, expected -0
4: got wrong results -0, expected 0
5: got wrong results 0, expected -0
6: got wrong results -0, expected 0
7: got wrong results 0, expected -0
8: got wrong results -0, expected 0
9: got wrong results 0, expected -0
10: got wrong results -0, expected 0
11: got wrong results 0, expected -0
12: got wrong results -0, expected 0
13: got wrong results 0, expected -0
14: got wrong results -0, expected 0
15: got wrong results 0, expected -0
16: got wrong results -0, expected 0
17: got wrong results 0, expected -0
18: got wrong results -0, expected 0
20: got wrong results 0, expected -0
22: got wrong results -0, expected 0
23: got wrong results 0, expected -0
24: got wrong results -0, expected 0
25: got wrong results 0, expected -0
26: got wrong results -0, expected 0
27: got wrong results 0, expected -0

Fixes commit 3fc063dee01da4f80920a14b7db637c8501d6fd4
("Make __strtod_internal tests type-generic").

Suggested-by: Joseph Myers <josmyers@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 weeks agoTest fclose on an unopened file.
Aaron Merey [Thu, 29 Aug 2024 16:02:25 +0000 (12:02 -0400)]
Test fclose on an unopened file.

Add new file libio/tst-fclosed-unopened.c that tests whether fclose on
an unopened file returns EOF.

Calling fclose on unopened files normally causes a use-after-free bug,
however the standard streams are an exception since they are not
deallocated by fclose.

fclose returning EOF for unopened files is not part of the external
contract but there are dependancies on this behaviour.  For example,
gnulib's close_stdout in lib/closeout.c.

Tested for x86_64.

Signed-off-by: Aaron Merey <amerey@redhat.com>
5 weeks agoFix memory leak on freopen error return (bug 32140)
Joseph Myers [Thu, 5 Sep 2024 11:16:59 +0000 (11:16 +0000)]
Fix memory leak on freopen error return (bug 32140)

As reported in bug 32140, freopen leaks the FILE object when it
returns NULL: there is no valid use of the FILE * pointer (including
passing to freopen again or to fclose) after such an error return, so
the underlying object should be freed.  Add code to free it.

Note 1: while I think it's clear from the relevant standards that the
object should be freed and the FILE * can't be used after the call in
this case (the stream is closed, which ends the lifetime of the FILE),
it's entirely possible that some existing code does in fact try to use
the existing FILE * in some way and could be broken by this change.
(Though the most common case for freopen may be stdin / stdout /
stderr, which _IO_deallocate_file explicitly checks for and does not
deallocate.)

Note 2: the deallocation is only done in the _IO_IS_FILEBUF case.
Other kinds of streams bypass all the freopen logic handling closing
the file, meaning a call to _IO_deallocate_file would neither be safe
(the FILE might still be linked into the list of all open FILEs) nor
sufficient (other internal memory allocations associated with the file
would not have been freed).  I think the validity of freopen for any
other kind of stream will need clarifying with the Austin Group, but
if it is valid in any such case (where "valid" means "not undefined
behavior so required to close the stream" rather than "required to
successfully associate the stream with the new file in cases where
fopen would work"), more significant changes would be needed to ensure
the stream gets fully closed.

Tested for x86_64.

5 weeks agoClear flags2 flags set from mode in freopen (bug 32134)
Joseph Myers [Thu, 5 Sep 2024 11:15:29 +0000 (11:15 +0000)]
Clear flags2 flags set from mode in freopen (bug 32134)

As reported in bug 32134, freopen does not clear the flags set in
fp->_flags2 by the "e", "m" or "c" mode characters.  Clear these so
that they can be set or not as appropriate from the mode string passed
to freopen.  The relevant test for "e" in tst-freopen2-main.c is
enabled accordingly; "c" is expected to be covered in a separately
written test (and while tst-freopen2-main.c does include transitions
to and from "m", that's not really a semantic flag intended to result
in behaving in an observably different way).

Tested for x86_64.

5 weeks agosupport: Add FUSE-based file system test framework to support/
Florian Weimer [Fri, 30 Aug 2024 19:52:53 +0000 (21:52 +0200)]
support: Add FUSE-based file system test framework to support/

This allows to monitor the exact file system operations
performed by glibc and inject errors.

Hurd does not have <sys/mount.h>.  To get the sources to compile
at least, the same approach as in support/test-container.c is used.

Reviewed-by: DJ Delorie <dj@redhat.com>
5 weeks agoLinux: readdir_r needs to report getdents failures (bug 32124)
Florian Weimer [Fri, 30 Aug 2024 19:52:23 +0000 (21:52 +0200)]
Linux: readdir_r needs to report getdents failures (bug 32124)

Upon error, return the errno value set by the __getdents call
in __readdir_unlocked.  Previously, kernel-reported errors
were ignored.

Reviewed-by: DJ Delorie <dj@redhat.com>
This page took 0.092486 seconds and 5 git commands to generate.