Commit Graph

41569 Commits

Author SHA1 Message Date
Florian Weimer
9802c0f2fe 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.
2024-09-24 13:23:10 +02:00
Florian Weimer
bdaf500353 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]").
2024-09-24 13:23:10 +02:00
Florian Weimer
8f6a53eab8 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.
2024-09-24 13:23:10 +02:00
Florian Weimer
7e21a65c58 misc: Enable internal use of memory protection keys
This adds the necessary hidden prototypes.
2024-09-24 13:23:10 +02:00
Florian Weimer
3ef26b7087 misc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library)
The barrier functions require this on Hurd.
2024-09-24 13:05:52 +02:00
Florian Weimer
079ebf7624 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>
2024-09-24 12:35:40 +02:00
Joe Ramsay
16a59571e4 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>
2024-09-23 15:44:08 +01:00
Joe Ramsay
7900ac490d 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>
2024-09-23 15:44:07 +01:00
Joe Ramsay
5bc100bd4b 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>
2024-09-23 15:44:07 +01:00
Joe Ramsay
a15b1394b5 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>
2024-09-23 15:44:07 +01:00
Joe Ramsay
7b8c134b54 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>
2024-09-23 15:44:07 +01:00
Florian Weimer
6f3f6c506c 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>
2024-09-21 19:32:34 +02:00
Florian Weimer
6aa1645f66 dirent: Add tst-rewinddir
It verifies that rewinddir allows restarting the directory
iteration.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-21 19:32:34 +02:00
Florian Weimer
4ec355af45 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>
2024-09-21 19:32:34 +02:00
Florian Weimer
e92718552e 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>
2024-09-21 19:32:34 +02:00
Florian Weimer
4c09aa31b1 dirent: Add tst-closedir-leaks
It verfies that closedir deallocates memory and closes
file descriptors.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-21 19:32:34 +02:00
Florian Weimer
366cce74d2 support: Add valgrind instructions to <support/fuse.h>
Replacing an outdated comment (namespace setup is now handled by
support_fuse_init).
2024-09-21 19:29:13 +02:00
Florian Weimer
455c762283 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.
2024-09-21 19:25:35 +02:00
Florian Weimer
e3db0a699c 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>
2024-09-21 19:25:35 +02:00
Joseph Myers
e0f3bf10ac 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.
2024-09-20 23:26:31 +00:00
Joseph Myers
94ca2c0894 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.
2024-09-20 23:25:32 +00:00
Joseph Myers
378039ca57 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.
2024-09-20 23:24:45 +00:00
Joseph Myers
b5d3737b30 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.
2024-09-20 23:24:02 +00:00
Joseph Myers
8de031bcb9 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.
2024-09-20 23:23:13 +00:00
Florian Weimer
d5a3ca4061 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>
2024-09-21 00:29:55 +02:00
Aaron Merey
83fd4149ff 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>
2024-09-20 15:49:36 -04:00
Aaron Merey
35dc62de3d 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>
2024-09-20 10:32:35 -04:00
Florian Weimer
fa1b0d5e9f 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>
2024-09-20 13:51:09 +02:00
Florian Weimer
75819cdd29 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>
2024-09-20 13:51:09 +02:00
Florian Weimer
8ef3cff9d1 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>
2024-09-20 13:51:09 +02:00
Florian Weimer
6cbf845fcd 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>
2024-09-20 13:51:09 +02:00
Florian Weimer
00ba299787 manual: __is_last is no longer part of iconv internals
The __is_last field was replaced with a bitmask in
commit 85830c4c46 in 2000,
and multiple bits are in use today.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-20 13:51:09 +02:00
Florian Weimer
0cb64617a6 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>
2024-09-20 13:51:09 +02:00
Florian Weimer
422ed8ede3 iconv: Base tests for buffer management
Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-20 13:51:09 +02:00
Joe Ramsay
751a5502be 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>
2024-09-19 17:53:34 +01:00
Sergey Bugaev
4524670545 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>
2024-09-19 14:18:39 +02:00
Yury Khrustalev
e64a1e81aa 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>
2024-09-14 12:54:18 +02:00
Florian Weimer
c9154cad66 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 1251e9ea49
("support: Add <support/readdir.h>").
2024-09-12 18:26:04 +02:00
Florian Weimer
1251e9ea49 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>
2024-09-12 09:40:45 +02:00
Florian Weimer
c444cc1d83 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>
2024-09-11 10:05:08 +02:00
Florian Weimer
21571ca0d7 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>
2024-09-11 10:05:08 +02:00
Florian Weimer
298bc488fd 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>
2024-09-11 10:05:08 +02:00
Wilco Dijkstra
8ecb477ea1 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>
2024-09-10 14:18:03 +01:00
Florian Weimer
89b088bf70 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”.
2024-09-10 12:40:27 +02:00
Florian Weimer
e82a7cb162 elf: Fix tst-dlopen-tlsreinit1.out test dependency
Fixes commit 5097cd344f
("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>
2024-09-09 21:10:23 +02:00
Tulio Magno Quites Machado Filho
dccc9a5161 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>
2024-09-09 15:58:07 -03:00
Tulio Magno Quites Machado Filho
5d4ab106d4 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>
2024-09-09 14:32:20 -03:00
Wilco Dijkstra
cec3aef324 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>
2024-09-09 15:30:00 +01:00
John David Anglin
3fc1d3bc33 hppa: Update libm-test-ulps 2024-09-09 09:57:42 -04:00
Joe Ramsay
8b09af572b 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>
2024-09-09 13:03:49 +01:00