about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* misc: FUSE-based tests for mkstempFlorian Weimer2024-09-213-0/+422
| | | | | | | | | | | 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>
* Add freopen special-case tests: chroot, EFBIG, stdin/stdout/stderrJoseph Myers2024-09-208-0/+385
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Make tst-strtod-underflow type-genericJoseph Myers2024-09-201-60/+297
| | | | | | | | | | | | 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.
* Add tests of more strtod special casesJoseph Myers2024-09-201-0/+14
| | | | | | | | | 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.
* Add more tests of strtod end pointerJoseph Myers2024-09-201-2/+39
| | | | | | | | | 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.
* Make tst-strtod2 and tst-strtod5 type-genericJoseph Myers2024-09-202-82/+118
| | | | | | | | | | | | | | 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.
* Implement run-built-tests=no for make xcheck, always build xtestsFlorian Weimer2024-09-211-6/+11
| | | | | | | | | | | | | | | | | | 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>
* Test that errno is set to 0 at program startupAaron Merey2024-09-202-0/+59
| | | | | | | | | | 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>
* Add another test for fclose on an unopened fileAaron Merey2024-09-204-3/+69
| | | | | | | | | | | | | | | | | 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>
* iconv: Input buffering for the iconv program (bug 6050)Florian Weimer2024-09-202-106/+109
| | | | | | Do not read the entire input file into memory. Reviewed-by: DJ Delorie <dj@redhat.com>
* iconv: Multiple - on command line should not fail (bug 32050)Florian Weimer2024-09-202-1/+7
| | | | | | | 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>
* iconv: Support in-place conversions (bug 10460, bug 32033)Florian Weimer2024-09-204-75/+386
| | | | | | | | | | | | 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>
* iconv: Preserve iconv -c error exit on invalid inputs (bug 32046)Florian Weimer2024-09-2016-108/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* manual: __is_last is no longer part of iconv internalsFlorian Weimer2024-09-201-9/+9
| | | | | | | | 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>
* iconv: Do not use mmap in iconv (the program) (bug 17703)Florian Weimer2024-09-201-41/+1
| | | | | | | | | | | | | 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>
* iconv: Base tests for buffer managementFlorian Weimer2024-09-202-2/+187
| | | | Reviewed-by: DJ Delorie <dj@redhat.com>
* AArch64: Add vector logp1 alias for log1pJoe Ramsay2024-09-1910-1/+42
| | | | | | | | 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>
* hurd: Avoid file_check_access () RPC for access (F_OK)Sergey Bugaev2024-09-191-0/+9
| | | | | | | | | | | | | | 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>
* tst: Extend cross-test-ssh.sh to support passing glibc tunablesYury Khrustalev2024-09-141-0/+18
| | | | | | | | | | | | | | | | | 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>
* support: Fix Hurd build of tst-support_readdirFlorian Weimer2024-09-121-4/+7
| | | | | | | | Check for the availability of the d_off member at compile time, not run time. Fixes commit 1251e9ea49fba9f53bbf4f290f3db90c01931fa7 ("support: Add <support/readdir.h>").
* support: Add <support/readdir.h>Florian Weimer2024-09-124-0/+475
| | | | | | | | | | | 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>
* Linux: Add missing scheduler constants to <sched.h>Florian Weimer2024-09-114-0/+82
| | | | | | | And add a test, misc/tst-sched-consts, that checks consistency with <sched.h>. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Add the sched_setattr and sched_getattr functionsFlorian Weimer2024-09-1141-2/+391
| | | | | | | | | | | | | | | | | | | | 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>
* manual: Extract the @manpageurl{func,sec} macroFlorian Weimer2024-09-111-2/+5
| | | | | | | | 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>
* AArch64: Remove memset-reg.hWilco Dijkstra2024-09-106-35/+28
| | | | | | | Remove memset-reg.h by moving register definitions into the memset implementations. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* debug: Fix read error handling in pcprofiledumpFlorian Weimer2024-09-101-36/+47
| | | | | | | | | | 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”.
* elf: Fix tst-dlopen-tlsreinit1.out test dependencyFlorian Weimer2024-09-091-1/+1
| | | | | | | | | 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>
* Add a new fwrite test for memory streamsTulio Magno Quites Machado Filho2024-09-092-0/+178
| | | | | | Ensure that fwrite() behaves correctly when using memory streams. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add a new fwrite test for read-only streamsTulio Magno Quites Machado Filho2024-09-092-0/+66
| | | | | | | Ensure that fwrite() behaves correctly even when the stream is read-only. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* AArch64: Optimize memsetWilco Dijkstra2024-09-091-111/+84
| | | | | | | | | 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>
* hppa: Update libm-test-ulpsJohn David Anglin2024-09-091-21/+21
|
* aarch64: Avoid redundant MOVs in AdvSIMD F32 logsJoe Ramsay2024-09-093-45/+72
| | | | | | | | | 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>
* io: Add FUSE-based test for fchmodFlorian Weimer2024-09-092-0/+115
| | | | | | | Test all mode arguments, and that extra bits are ignored as required by POSIX. Reviewed-by: DJ Delorie <dj@redhat.com>
* io: Add tst-lstat-nofollow, tst-lstat-nofollow-time64Florian Weimer2024-09-093-0/+101
| | | | | | They verify that lstat, lstat64 do not follow symbolic links. Reviewed-by: DJ Delorie <dj@redhat.com>
* Document limitations on streams passed to freopenJoseph Myers2024-09-061-0/+8
| | | | | | | | | | 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".
* stdlib: Do not use GLIBC_PRIVATE ABI for errno in libc_nonshared.aFlorian Weimer2024-09-061-1/+1
| | | | | | | | | | | | | 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>
* manual: Safety annotations for clock_gettime, clock_getresFlorian Weimer2024-09-061-0/+2
| | | | | | | The annotations are preliminary, for consistency with existing annotations on gettimeofday etc. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* LoongArch: Fix macro redefined warning in tls-desc.Smengqinggang2024-09-062-6/+15
| | | | Undef macro to avoid redefined warning.
* timezone: sync to TZDB 2024bAdhemerval Zanella2024-09-056-142/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* i386: Update ulpsFlorian Weimer2024-09-051-3/+3
| | | | | As seen on an AMD Ryzen 9 7950X CPU when building with GCC 14 with SSE2 math.
* Fix freopen handling of ,ccs= (bug 23675)Joseph Myers2024-09-053-11/+3
| | | | | | | | | | | | | 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.
* powerpc64le: Build new strtod tests with long double ABI flags (bug 32145)Florian Weimer2024-09-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Test fclose on an unopened file.Aaron Merey2024-09-052-0/+41
| | | | | | | | | | | | | | | | | 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>
* Fix memory leak on freopen error return (bug 32140)Joseph Myers2024-09-054-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Clear flags2 flags set from mode in freopen (bug 32134)Joseph Myers2024-09-053-2/+9
| | | | | | | | | | | | | 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.
* support: Add FUSE-based file system test framework to support/Florian Weimer2024-09-054-0/+1270
| | | | | | | | | | 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>
* Linux: readdir_r needs to report getdents failures (bug 32124)Florian Weimer2024-09-051-1/+10
| | | | | | | | 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>
* support: Add <support/xdirent.h>Florian Weimer2024-09-058-0/+321
| | | | | | | | Use static functions for readdir/readdir_r, so that -D_FILE_OFFSET_BITS=64 does not improperly redirect calls to the wrong implementation. Reviewed-by: DJ Delorie <dj@redhat.com>
* Bundle <linux/fuse.h> userspace header from Linux 6.10Florian Weimer2024-09-055-0/+1597
| | | | | | | | | | | | | | | And include the required licensing information. The only change is a removed trailing empty line in LICENSES/exceptions/Linux-syscall-note. Bundling <linux/fuse.h> is the recommended way to deal with the evolution of the FUSE userspace interface because structs change sizes over time. The kernel maintains compatibility, but source-level compatibility on recompilation may require additional code that is aware of older struct sizes. Signed-off-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: DJ Delorie <dj@redhat.com>
* i386: Update ulpsFlorian Weimer2024-09-051-1/+1
| | | | | As seen on an unspecified Intel system with glibc compiled with GCC 8.