about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
...
* Add more thorough tests of freopenJoseph Myers2024-09-047-0/+642
| | | | | | | | | | | | | | | | | | | | | freopen is rather minimally tested in libio/tst-freopen and libio/test-freopen. Add some more thorough tests, covering different cases for change of mode in particular. The tests are run for both freopen and freopen64 (given that those functions have two separate copies of much of the code, so any bug fix directly in the freopen code would probably need applying in both places). Note that there are two parts of the tests disabled because of bugs discovered through running the tests, with bug numbers given in comments. I expect to address those separately. The tests also don't cover changes to cancellation ("c" in mode); I think that will better be handled through a separate test. Also to handle separately: testing on stdin / stdout / stderr; documenting lack of support for streams opened with popen / fmemopen / open_memstream / fopencookie; maybe also a chroot test without /proc; maybe also more thorough tests for large file handling on 32-bit systems (freopen64). Tested for x86_64.
* libio: Attempt wide backup free only for non-legacy codeSiddhesh Poyarekar2024-09-041-1/+1
| | | | | | | | | | _wide_data and _mode are not available in legacy code, so do not attempt to free the wide backup buffer in legacy code. Resolves: BZ #32137 and BZ #27821 Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Do not set errno for overflowing NaN payload in strtod/nan (bug 32045)Joseph Myers2024-09-043-0/+57
| | | | | | | | | | | As reported in bug 32045, it's incorrect for strtod/nan functions to set errno based on overflowing payload (strtod should only set errno for overflow / underflow of its actual result, and potentially if nothing in the string can be parsed as a number at all; nan should be a pure function that never sets it). Save and restore errno around the internal strtoull call and add associated test coverage. Tested for x86_64.
* Improve NaN payload testingJoseph Myers2024-09-041-5/+54
| | | | | | | | | | | | | | | | | | | | | | There are two separate sets of tests of NaN payloads in glibc: * libm-test-{get,set}payload* verify that getpayload, setpayload, setpayloadsig and __builtin_nan functions are consistent in their payload handling. * test-nan-payload verifies that strtod-family functions and the not-built-in nan functions are consistent in their payload handling. Nothing, however, connects the two sets of functions (i.e., verifies that strtod / nan are consistent with getpayload / setpayload / __builtin_nan). Improve test-nan-payload to check actual payload value with getpayload rather than just verifying that the strtod and nan functions produce the same NaN. Also check that the NaNs produced aren't signaling and extend the tests to cover _FloatN / _FloatNx. Tested for x86_64.
* Add support/ code for checking file contentsJoseph Myers2024-09-036-0/+202
| | | | | | | For use in freopen tests, add various support/ helper interfaces for use in checking file contents. Tested for x86_64.
* linux: mips: Fix syscall_cancell build for __mips_isa_rev >= 6Adhemerval Zanella2024-09-021-0/+4
| | | | | | | Use beqzc instead of bnel. Checked with a mipsisa64r6el-n64-linux-gnu build and some nptl cancellation tests on qemu.
* io: Fix destructive nature of tst-fchmod-errorsFlorian Weimer2024-08-301-3/+10
| | | | | | | We must not change the permissions of /dev/null if running as root. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* io: Add error tests for fchmodFlorian Weimer2024-08-302-0/+57
| | | | | | | | | | On Linux most descriptors that do not correspond to file system entities (such as anonymous pipes and sockets) have file permissions that can be changed. While it is possible to create a custom file system that returns (say) EINVAL for an fchmod attempt, testing this does not appear to be useful. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* powerpc64: Fix syscall_cancel build for powerpc64le-linux-gnu [BZ #32125]Jeevitha Palanisamy2024-08-301-1/+1
| | | | | | | | | In __syscall_cancel_arch, there's a tail call to __syscall_do_cancel. On P10, since the caller uses the TOC and the callee is using PC-relative addressing, there's only a branch instruction with no NOPs to restore the TOC, which causes the build error. The fix involves adding the NOTOC directive to the branch instruction, informing the linker not to generate a TOC stub, thus resolving the issue.
* Make __strtod_internal tests type-genericJoseph Myers2024-08-274-180/+313
| | | | | | | | | | | | | | | | | | 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 the tests of the internal __strtod_internal interface to cover 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. As an internal interface, there are no aliases for different types with the same ABI (however, __strtold_internal is defined even if long double has the same ABI as double), so macros used by the type-generic testing code are redefined as needed to avoid expecting such aliases to be present. Tested for x86_64.
* Fix strtod subnormal rounding (bug 30220)Joseph Myers2024-08-273-0/+386
| | | | | | | | | | | | | | | | | | | | As reported in bug 30220, the implementation of strtod-family functions has a bug in the following case: the input string would, with infinite exponent range, take one more bit to represent than is available in the normal precision of the return type; the value represented is in the subnormal range; and there are no nonzero bits in the value, below those that can be represented in subnormal precision, other than the least significant bit and possibly the 0.5ulp bit. In this case, round_and_return ends up discarding the least significant bit. Fix by saving that bit to merge into more_bits (it can't be merged in at the time it's computed, because more_bits mustn't include this bit in the case of after-rounding tininess detection checking if the result is still subnormal when rounded to normal precision, so merging this bit into more_bits needs to take place after that check). Tested for x86_64.
* More thoroughly test underflow / errno in tst-strtod-roundJoseph Myers2024-08-273-7761/+7857
| | | | | | | | | | | | | | | | | | | Add tests of underflow in tst-strtod-round, and thus also test for errno being unchanged when there is neither overflow nor underflow. The errno setting before the function call to test for being unchanged is adjusted to set errno to 12345 instead of 0, so that any bugs where strtod sets errno to 0 would be detected. This doesn't add any new test inputs for tst-strtod-round, and in particular doesn't cover the edge cases of underflow the way tst-strtod-underflow does (none of the existing test inputs for tst-strtod-round actually exercise cases that have underflow with before-rounding tininess detection but not with after-rounding tininess detection), but at least it provides some coverage (as per the recent discussions) that ordinary non-overflowing non-underflowing inputs to these functions do not set errno. Tested for x86_64.
* manual: Add Descriptor-Relative Access sectionFlorian Weimer2024-08-273-10/+235
| | | | | | | | | | | Reference this new section from the O_PATH documentation. And document the functions openat, openat64, fstatat, fstatat64. (The safety assessment for fstatat was already obsolete because current glibc assumes kernel support for the underlying system call.) Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Enable non-temporal memset for Hygon processorsFeifei Wang2024-08-262-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch uses 'Avoid_Non_Temporal_Memset' flag to access the non-temporal memset implementation for hygon processors. Test Results: hygon1 arch x86_memset_non_temporal_threshold = 8MB size new performance time / old performance time 1MB 0.994 4MB 0.996 8MB 0.670 16MB 0.343 32MB 0.355 hygon2 arch x86_memset_non_temporal_threshold = 8MB size new performance time / old performance time 1MB 1 4MB 1 8MB 1.312 16MB 0.822 32MB 0.830 hygon3 arch x86_memset_non_temporal_threshold = 8MB size new performance time / old performance time 1MB 1 4MB 0.990 8MB 0.737 16MB 0.390 32MB 0.401 For hygon arch with this patch, non-temporal stores can improve performance by 20% - 65%. Signed-off-by: Feifei Wang <wangfeifei@hygon.cn> Reviewed-by: Jing Li <lijing@hygon.cn> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Add cache information support for Hygon processorsFeifei Wang2024-08-261-0/+60
| | | | | | | | | | Add hygon branch in dl_init_cacheinfo function to initialize cache size variables for hygon processors. In the meanwhile, add handle_hygon() function to get cache information. Signed-off-by: Feifei Wang <wangfeifei@hygon.cn> Reviewed-by: Jing Li <lijing@hygon.cn> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Add new architecture type for Hygon processorsFeifei Wang2024-08-262-3/+17
| | | | | | | | | | Add a new architecture type arch_kind_hygon to spilt Hygon branch from AMD. This is to facilitate the Hygon processors to make settings that are suitable for its own characteristics. Signed-off-by: Feifei Wang <wangfeifei@hygon.cn> Reviewed-by: Jing Li <lijing@hygon.cn> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* support: Report errno constants in TEST_COMPARE failuresFlorian Weimer2024-08-261-1/+10
| | | | | | | If the expression is errno, decode it as an errno constant using strerrorname_np. Reviewed-by: Arjun Shankar <arjun@redhat.com>
* inet: Avoid label at end of compound statement in tst-if_nameindexFlorian Weimer2024-08-261-0/+1
| | | | This fails to compile with GCC 8.
* mach: Fix bogus negative returnSamuel Thibault2024-08-251-0/+3
| | | | | | | | One can be very unlucky to call time_now first just before a second switch, and mach_msg sleep just a bit more enough for the second time_now call to count one second too many (or even more if scheduling is really unlucky). So we have to protect against returning a bogus negative value in such case.
* powerpc64: Optimize strcpy and stpcpy for Power9/10Mahesh Bodapati2024-08-231-53/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch modifies the current Power9 implementation of strcpy and stpcpy to optimize it for Power9 and Power10. No new Power10 instructions are used, so the original Power9 strcpy is modified instead of creating a new implementation for Power10. The changes also affect stpcpy, which uses the same implementation with some additional code before returning. Improvements compared to the old Power9 version: Use simple comparisons for the first ~512 bytes: The main loop is good for long strings, but comparing 16B each time is better for shorter strings. After aligning the address to 16 bytes, we unroll the loop four times, checking 128 bytes each time. There may be some overlap with the main loop for unaligned strings, but it is better for shorter strings. Loop with 64 bytes for longer bytes: Use 4 consecutive lxv/stxv instructions. Showed an average improvement of 13%. Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com> Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
* nptl: Fix Race conditions in pthread cancellation [BZ#12683]Adhemerval Zanella2024-08-2353-228/+2521
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current racy approach is to enable asynchronous cancellation before making the syscall and restore the previous cancellation type once the syscall returns, and check if cancellation has happen during the cancellation entrypoint. As described in BZ#12683, this approach shows 2 problems: 1. Cancellation can act after the syscall has returned from the kernel, but before userspace saves the return value. It might result in a resource leak if the syscall allocated a resource or a side effect (partial read/write), and there is no way to program handle it with cancellation handlers. 2. If a signal is handled while the thread is blocked at a cancellable syscall, the entire signal handler runs with asynchronous cancellation enabled. This can lead to issues if the signal handler call functions which are async-signal-safe but not async-cancel-safe. For the cancellation to work correctly, there are 5 points at which the cancellation signal could arrive: [ ... )[ ... )[ syscall ]( ... 1 2 3 4 5 1. Before initial testcancel, e.g. [*... testcancel) 2. Between testcancel and syscall start, e.g. [testcancel...syscall start) 3. While syscall is blocked and no side effects have yet taken place, e.g. [ syscall ] 4. Same as 3 but with side-effects having occurred (e.g. a partial read or write). 5. After syscall end e.g. (syscall end...*] And libc wants to act on cancellation in cases 1, 2, and 3 but not in cases 4 or 5. For the 4 and 5 cases, the cancellation will eventually happen in the next cancellable entrypoint without any further external event. The proposed solution for each case is: 1. Do a conditional branch based on whether the thread has received a cancellation request; 2. It can be caught by the signal handler determining that the saved program counter (from the ucontext_t) is in some address range beginning just before the "testcancel" and ending with the syscall instruction. 3. SIGCANCEL can be caught by the signal handler and determine that the saved program counter (from the ucontext_t) is in the address range beginning just before "testcancel" and ending with the first uninterruptable (via a signal) syscall instruction that enters the kernel. 4. In this case, except for certain syscalls that ALWAYS fail with EINTR even for non-interrupting signals, the kernel will reset the program counter to point at the syscall instruction during signal handling, so that the syscall is restarted when the signal handler returns. So, from the signal handler's standpoint, this looks the same as case 2, and thus it's taken care of. 5. For syscalls with side-effects, the kernel cannot restart the syscall; when it's interrupted by a signal, the kernel must cause the syscall to return with whatever partial result is obtained (e.g. partial read or write). 6. The saved program counter points just after the syscall instruction, so the signal handler won't act on cancellation. This is similar to 4. since the program counter is past the syscall instruction. So The proposed fixes are: 1. Remove the enable_asynccancel/disable_asynccancel function usage in cancellable syscall definition and instead make them call a common symbol that will check if cancellation is enabled (__syscall_cancel at nptl/cancellation.c), call the arch-specific cancellable entry-point (__syscall_cancel_arch), and cancel the thread when required. 2. Provide an arch-specific generic system call wrapper function that contains global markers. These markers will be used in SIGCANCEL signal handler to check if the interruption has been called in a valid syscall and if the syscalls has side-effects. A reference implementation sysdeps/unix/sysv/linux/syscall_cancel.c is provided. However, the markers may not be set on correct expected places depending on how INTERNAL_SYSCALL_NCS is implemented by the architecture. It is expected that all architectures add an arch-specific implementation. 3. Rewrite SIGCANCEL asynchronous handler to check for both canceling type and if current IP from signal handler falls between the global markers and act accordingly. 4. Adjust libc code to replace LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET to use the appropriate cancelable syscalls. 5. Adjust 'lowlevellock-futex.h' arch-specific implementations to provide cancelable futex calls. Some architectures require specific support on syscall handling: * On i386 the syscall cancel bridge needs to use the old int80 instruction because the optimized vDSO symbol the resulting PC value for an interrupted syscall points to an address outside the expected markers in __syscall_cancel_arch. It has been discussed in LKML [1] on how kernel could help userland to accomplish it, but afaik discussion has stalled. Also, sysenter should not be used directly by libc since its calling convention is set by the kernel depending of the underlying x86 chip (check kernel commit 30bfa7b3488bfb1bb75c9f50a5fcac1832970c60). * mips o32 is the only kABI that requires 7 argument syscall, and to avoid add a requirement on all architectures to support it, mips support is added with extra internal defines. Checked on aarch64-linux-gnu, arm-linux-gnueabihf, powerpc-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, i686-linux-gnu, and x86_64-linux-gnu. [1] https://lkml.org/lkml/2016/3/8/1105 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Test mkdirat use of mode argumentJoseph Myers2024-08-221-0/+42
| | | | | | | | The test io/tst-mkdirat doesn't verify the permissions on the created directory (thus, doesn't verify at all anything about how mkdirat uses the mode argument). Add checks of this to the existing test. Tested for x86_64.
* Add more tests of getlineJoseph Myers2024-08-213-0/+543
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is very little test coverage for getline (only a minimal stdio-common/tstgetln.c which doesn't verify anything about the results of the getline calls). Add some more thorough tests (generally using fopencookie for convenience in testing various cases for what the input and possible errors / EOF in the file read might look like). Note the following regarding testing of error cases: * Nothing is said in the specifications about what if anything might be written into the buffer, and whether it might be reallocated, in error cases. The expectation of the tests (required to avoid memory leaks on error) is that at least on error cases, the invariant that lineptr points to at least n bytes is maintained. * The optional EOVERFLOW error case specified in POSIX, "The number of bytes to be written into the buffer, including the delimiter character (if encountered), would exceed {SSIZE_MAX}.", doesn't seem practically testable, as any case reading so many characters (half the address space) would also be liable to run into allocation failure along (ENOMEM) the way. * If a read error occurs part way through reading an input line, it seems unclear whether a partial line should be returned by getline (avoid input getting lost), which is what glibc does at least in the fopencookie case used in this test, or whether getline should return -1 (error) (so avoiding the program misbehaving by processing a truncated line as if it were complete). (There was a short, inconclusive discussion about this on the Austin Group list on 9-10 November 2014.) * The POSIX specification of getline inherits errors from fgetc. I didn't try to cover fgetc errors systematically, just one example of such an error. Tested for x86_64 and x86.
* Revert "inet: Avoid label at end of compound statement in tst-if_nameindex"Florian Weimer2024-08-211-1/+3
| | | | | | This reverts commit 26aca73db5e5ea299b554ceae418b13102b24948. Reason for revert: Unintended semantic change.
* inet: Avoid label at end of compound statement in tst-if_nameindexFlorian Weimer2024-08-211-3/+1
| | | | This fails to compile with GCC 8.
* Rules: Also build memcheck tests even when not running themSamuel Thibault2024-08-201-1/+5
| | | | | | | This will avoid in the future cases like a57cbbd85379 ("malloc: Link threading tests with $(shared-thread-library") missing the memcheck cases added in 251843e16fce ("malloc: Link threading tests with $(shared-thread-library)")
* malloc: Link threading tests with $(shared-thread-library)Samuel Thibault2024-08-201-0/+6
| | | | Fixes build failures on Hurd.
* inet: test if_nametoindex and if_indextonameDJ Delorie2024-08-192-0/+117
| | | | | | | | | | Tests for if_nameindex, if_name2index, and if_index2name Tests that valid results are consistent. Tests that invalid parameters fail correctly. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* elf: Make dl-fptr and dl-symaddr hppa specificAdhemerval Zanella2024-08-194-401/+22
| | | | | | | | With ia64 removal, the function descriptor supports is only used by HPPA and new architectures do not seem leaning towards this design. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* x86: Unifies 'strnlen-evex' and 'strnlen-evex512' implementations.Matthew Sterrett2024-08-193-680/+469
| | | | | | | | | | | | | | | | | | | | This commit uses a common implementation 'strnlen-evex-base.S' for both 'strnlen-evex' and 'strnlen-evex512' This patch serves both to reduce the number of implementations, and it also does some small optimizations that benefit strnlen-evex and strnlen-evex512. All tests pass on x86. Benchmarks were taken on SKX. https://www.intel.com/content/www/us/en/products/sku/123613/intel-core-i97900x-xseries-processor-13-75m-cache-up-to-4-30-ghz/specifications.html Geometric mean for strnlen-evex over all benchmarks (N=10) was (new/old) 0.881 Geometric mean for strnlen-evex512 over all benchmarks (N=10) was (new/old) 0.953 Code Size Changes: strnlen-evex : +31 bytes strnlen-evex512 : +156 bytes Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* string: strerror, strsignal cannot use buffer after dlmopen (bug 32026)Florian Weimer2024-08-192-25/+46
| | | | | | | | | | | | | | | | | Secondary namespaces have a different malloc. Allocating the buffer in one namespace and freeing it another results in heap corruption. Fix this by using a static string (potentially translated) in secondary namespaces. It would also be possible to use the malloc from the initial namespace to manage the buffer, but these functions would still not be safe to use in auditors etc. because a call to strerror could still free a buffer while it is used by the application. Another approach could use proper initial-exec TLS, duplicated in secondary namespaces, but that would need a callback interface for freeing libc resources in namespaces on thread exit, which does not exist today. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Use macros for *stat wrappersFlorian Weimer2024-08-1616-168/+34
| | | | | | | | | | | | Macros will automatically use the correct types, without having to fiddle with internal glibc macros. It's also impossible to get the types wrong due to aliasing because support_check_stat_fd and support_check_stat_path do not depend on the struct stat* types. The changes reveal some inconsistencies in tests. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* io: Use struct statx and xstatx in testsFlorian Weimer2024-08-1614-95/+57
| | | | | | | | This avoids the need to define struct_statx to an appropriate struct stat type variant because struct statx does not change based on time/file offset flags. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Add the xstatx functionFlorian Weimer2024-08-163-0/+35
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Include <string.h> for strcmp in support_format_addrinfo.cFlorian Weimer2024-08-161-0/+1
| | | | | | | This is currently implied by the internal headers, but it makes sense not to rely on this. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Remove #include <config.h>Florian Weimer2024-08-162-2/+0
| | | | | | | This is not needed: include/intprops.h has its own detection logic. It makes building these files outside of glibc easer. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Fix extraneous testing run by tst-rseq-nptl in the test driverMaciej W. Rozycki2024-08-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix an issue with commit 8f4632deb354 ("Linux: rseq registration tests") and prevent testing from being run in the process of the test driver itself rather than just the test child where one has been forked. The problem here is the unguarded use of a destructor to call a part of the testing. The destructor function, 'do_rseq_destructor_test' is called implicitly at program completion, however because it is associated with the executable itself rather than an individual process, it is called both in the test child *and* in the test driver itself. Prevent this from happening by providing a guard variable that only enables test invocation from 'do_rseq_destructor_test' in the process that has first run 'do_test'. Consequently extra testing is invoked from 'do_rseq_destructor_test' only once and in the correct process, regardless of the use or the lack of of the '--direct' option. Where called in the controlling test driver process that has neved called 'do_test' the destructor function silently returns right away without taking any further actions, letting the test driver fail gracefully where applicable. This arrangement prevents 'tst-rseq-nptl' from ever causing testing to hang forever and never complete, such as currently happening with the 'mips-linux-gnu' (o32 ABI) target. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Report error if setaffinity wrapper fails (Bug 32040)Carlos O'Donell2024-08-151-1/+1
| | | | | | | | | | | | Previously if the setaffinity wrapper failed the rest of the subtest would not execute and the current subtest would be reported as passing. Now if the setaffinity wrapper fails the subtest is correctly reported as faling. Tested manually by changing the conditions of the affinity call including setting size to zero, or checking the wrong condition. No regressions on x86_64. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* ungetc: Fix backup buffer leak on program exit [BZ #27821]Siddhesh Poyarekar2024-08-154-2/+47
| | | | | | | | | | | | | | | | | | | | | If a file descriptor is left unclosed and is cleaned up by _IO_cleanup on exit, its backup buffer remains unfreed, registering as a leak in valgrind. This is not strictly an issue since (1) the program should ideally be closing the stream once it's not in use and (2) the program is about to exit anyway, so keeping the backup buffer around a wee bit longer isn't a real problem. Free it anyway to keep valgrind happy when the streams in question are the standard ones, i.e. stdout, stdin or stderr. Also, the _IO_have_backup macro checks for _IO_save_base, which is a roundabout way to check for a backup buffer instead of directly looking for _IO_backup_base. The roundabout check breaks when the main get area has not been used and user pushes a char into the backup buffer with ungetc. Fix this to use the _IO_backup_base directly. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* ungetc: Fix uninitialized read when putting into unused streams [BZ #27821]Siddhesh Poyarekar2024-08-153-6/+6
| | | | | | | | | | | | | | | | | | | | When ungetc is called on an unused stream, the backup buffer is allocated without the main get area being present. This results in every subsequent ungetc (as the stream remains in the backup area) checking uninitialized memory in the backup buffer when trying to put a character back into the stream. Avoid comparing the input character with buffer contents when in backup to avoid this uninitialized read. The uninitialized read is harmless in this context since the location is promptly overwritten with the input character, thus fulfilling ungetc functionality. Also adjust wording in the manual to drop the paragraph that says glibc cannot do multiple ungetc back to back since with this change, ungetc can actually do this. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Make tst-ungetc use libsupportSiddhesh Poyarekar2024-08-151-55/+57
| | | | | Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* x86: Add `Avoid_STOSB` tunable to allow NT memset without ERMSNoah Goldstein2024-08-156-12/+53
| | | | | | | | | | | | | | | | | | | The goal of this flag is to allow targets which don't prefer/have ERMS to still access the non-temporal memset implementation. There are 4 cases for tuning memset: 1) `Avoid_STOSB && Avoid_Non_Temporal_Memset` - Memset with temporal stores 2) `Avoid_STOSB && !Avoid_Non_Temporal_Memset` - Memset with temporal/non-temporal stores. Non-temporal path goes through `rep stosb` path. We accomplish this by setting `x86_rep_stosb_threshold` to `x86_memset_non_temporal_threshold`. 3) `!Avoid_STOSB && Avoid_Non_Temporal_Memset` - Memset with temporal stores/`rep stosb` 3) `!Avoid_STOSB && !Avoid_Non_Temporal_Memset` - Memset with temporal stores/`rep stosb`/non-temporal stores. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Use `Avoid_Non_Temporal_Memset` to control non-temporal pathNoah Goldstein2024-08-152-8/+23
| | | | | | | | | | This is just a refactor and there should be no behavioral change from this commit. The goal is to make `Avoid_Non_Temporal_Memset` a more universal knob for controlling whether we use non-temporal memset rather than having extra logic based on vendor. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Fix bug in strchrnul-evex512 [BZ #32078]Noah Goldstein2024-08-152-5/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue was we were expecting not matches with CHAR before the start of the string in the page cross case. The check code in the page cross case: ``` and $0xffffffffffffffc0,%rax vmovdqa64 (%rax),%zmm17 vpcmpneqb %zmm17,%zmm16,%k1 vptestmb %zmm17,%zmm17,%k0{%k1} kmovq %k0,%rax inc %rax shr %cl,%rax je L(continue) ``` expects that all characters that neither match null nor CHAR will be 1s in `rax` prior to the `inc`. Then the `inc` will overflow all of the 1s where no relevant match was found. This is incorrect in the page-cross case, as the `vmovdqa64 (%rax),%zmm17` loads from before the start of the input string. If there are matches with CHAR before the start of the string, `rax` won't properly overflow. The fix is quite simple. Just replace: ``` inc %rax shr %cl,%rax ``` With: ``` sar %cl,%rax inc %rax ``` The arithmetic shift will clear any matches prior to the start of the string while maintaining the signbit so the 1s can properly overflow to zero in the case of no matches. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Test errno setting on strtod overflow in tst-strtod-roundJoseph Myers2024-08-141-0/+11
| | | | | | | | We have no tests that errno is set to ERANGE on overflow of strtod-family functions (we do have some tests for underflow, in tst-strtod-underflow). Add such tests to tst-strtod-round. Tested for x86_64.
* libio/tst-getdelim: Add new test covering NUL as a delimiterFrédéric Bérat2024-08-141-1/+21
| | | | | | | Add a new test to getdelim to verify that '\0' can be set as a delimiter. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* manual: Document dprintf and vdprintfFlorian Weimer2024-08-131-0/+27
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* manual: Document generic printf error codesFlorian Weimer2024-08-131-0/+23
| | | | | | Describe EOVERFLOW, ENOMEN, EILSEQ. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* ARC: Regenerate ULPsPavel Kozlov2024-08-112-0/+81
| | | | | | Regenerate fpu and soft-fp ULPs. Based on results from HSDK-4xD board with GCC 14 build. Including new tests added by 07972839108495245d8b93ca546462b3f4dad47f.
* support: Add options list terminator to the test driverFlorian Weimer2024-08-091-0/+1
| | | | | | This avoids crashes if a test is passed unknown options. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>