1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-04-28 06:33:36 +00:00
Commit Graph

27691 Commits

Author SHA1 Message Date
Jim Meyering
76eb993a7b regex: avoid a UBSAN failure: remove an unnecessary DEBUG_ASSERT
* lib/regex_internal.c (re_node_set_insert): Remove the DEBUG_ASSERT
and instead return early for an attempt to insert an ELEM that is
already present in the set.  Relax the function's comment that says
there should be no duplicate.  This function is called from many
places and has been working fine.  With its nontrivial backrefs,
the sample regexp apparently elicits enough backtracking retries
and state-set merges to trigger this duplicate insertion attempt.
Reported by Bruno Haible in
https://lists.gnu.org/r/bug-gnulib/2026-04/msg00138.html
2026-04-19 09:54:22 -07:00
Bruno Haible
1a8421ada2 regex tests: Add a test case that triggers an assertion failure.
* tests/test-regex.c (main): Add a test case related to back references.
2026-04-19 15:18:55 +02:00
Collin Funk
d8d9e3289f readutmp: Silence -Wzero-as-null-pointer-constant warning.
* lib/readutmp.c (read_utmp_from_systemd): Initialize all of the struct
members and use NULL for the pointer.
2026-04-18 19:48:16 -07:00
Paul Eggert
d8e2a2e266 doc: doc FTS_NOSTAT with FIFO, not directory
* lib/fts.in.h (FTS_NOSTAT): Use a FIFO, not a directory,
in the commentary’s example.  This is a better example
because directories never have FTS_NSOK.
2026-04-17 09:14:49 -07:00
Collin Funk
b6e096af38 regex: Silence -Wzero-as-null-pointer-constant warning.
* lib/regexec.c (merge_state_with_log): Check the pointer against NULL.
2026-04-16 21:50:27 -07:00
Bruno Haible
acff3d2250 byteswap: Fix compilation on Solaris OpenIndiana (regr. 2026-03-20).
* lib/byteswap.in.h: Include <stdint.h>.
* modules/byteswap (Depends-on): Add stdint-h.
2026-04-16 18:49:36 +02:00
Bruno Haible
0d791d4881 sigdelay: Don't use out-of-range signal numbers.
* lib/sigdelay.c (states): Change number of elements to NSIG.
2026-04-16 14:15:52 +02:00
Bruno Haible
9bb54c2fe5 sigdelay, posix-spawn-internal: Ignore out-of-range signal numbers.
* lib/sigdelay.c (sigdelay): Do nothing when sigismember() returns -1.
* lib/spawni.c (__spawni): Likewise.
2026-04-16 14:14:38 +02:00
Bruno Haible
2b070755bc sigprocmask: Fix sigismember function.
* lib/sigprocmask.c (sigismember): If the signal argument is invalid,
return -1 instead of 0.
2026-04-16 13:03:39 +02:00
Bruno Haible
a297266a67 pthread_sigmask tests: Fix test failure on Solaris, AIX (regr. today).
Reported by Pádraig Brady.

* tests/test-pthread_sigmask2.c (main): Reestablish the signal handler
after SIGINT arrived.
* tests/test-sigdelay2.c (main): Likewise.
2026-04-16 00:29:42 +02:00
Paul Eggert
9ab4bbed73 doc: doc FTS_NOSTAT similarity to FTS_DEFER_STAT
* lib/fts.in.h (FTS_NOSTAT, FTS_DEFER_STAT):
Document that FTS_NOSTAT updates fts_statp->st_mode
similarly with FTS_DEFER_STAT.
2026-04-15 14:47:55 -07:00
Paul Eggert
f5ee21eacc fts: match doc for FTS_DEFER_STAT mode
* lib/fts.c (fts_open): Clear fts_statp->fts_mode for the
FTS_DEFER_STAT case too, since it’s documented to work since 2008.
2026-04-15 14:45:53 -07:00
Bruno Haible
001a315786 sigdelay: Add tests.
* tests/test-sigdelay1.c: New file, based on
tests/test-pthread_sigmask1.c.
* tests/test-sigdelay2.c: New file, based on
tests/test-pthread_sigmask2.c.
* modules/sigdelay-tests: New file.
2026-04-15 13:46:08 +02:00
Bruno Haible
006d544083 sigdelay: New module.
* lib/sigdelay.h: New file.
* lib/sigdelay.c: New file.
* modules/sigdelay: New file.
2026-04-15 13:45:52 +02:00
Bruno Haible
2448235dbf pthread_sigmask tests: Enhance test.
* tests/test-pthread_sigmask2.c (killer_thread1): Renamed from
killer_thread.
(killer_thread2): New variable.
(killer_thread1_func): Renamed from killer_thread_func.
(killer_thread2_func): New function.
(main): Add a second test with killer_thread2.
2026-04-15 13:45:44 +02:00
Bruno Haible
3daeaa60a1 pthread_sigmask tests: More details about VirtualBox / KVM bug.
* tests/test-pthread_sigmask1.c (main): Refine comment regarding
VirtualBox / KVM bug.
* tests/test-pthread_sigmask2.c (main): Likewise.
2026-04-15 13:45:35 +02:00
Bruno Haible
1943cae989 sigprocmask: On mingw, avoid dependency on libwinpthread.
* lib/sigprocmask.c: Include windows-tls.h, windows-once.h.
(thread_local): Remove macro.
(struct per_thread): New type.
(tls_key): New variable.
(keys_init): New function.
(keys_init_once): New variable.
(get_per_thread): New function.
(per_thread_singleton): New variable.
(blocked_set, pending_array): Remove variables.
(sigpending, override_handler, pthread_sigmask, _gl_raise_SIGPIPE):
Invoke get_per_thread, to access blocked_set or pending_array.
* modules/sigprocmask (Depends-on): Add windows-once, windows-tls.
2026-04-14 21:56:00 +02:00
Bruno Haible
e304c84784 sigaction: Fix test failure on native Windows.
* lib/sigaction.c (sigaction): Hide the sigaction_handler from the
caller.
2026-04-14 20:38:58 +02:00
Paul Eggert
acbecf6ea2 error_h: fix icx version in commentary 2026-04-13 19:19:09 -07:00
Bruno Haible
e1532bc0fe stdbit-h: Port to Intel icpx C++ compiler.
* lib/stdbit.in.h: With the Intel icpx C++ compiler, include <stddef.h>
and <stdint.h>, and define the __STDC_ENDIAN_* macros.
* doc/posix-headers/stdbit.texi: Document the Intel icpx bug.
2026-04-13 23:44:57 +02:00
Paul Eggert
67f60dc421 error-h: port to Intel OneAPI icx 2026.0.0
Problem reported by Harmen Stoppels in:
https://lists.gnu.org/r/bug-gnulib/2026-04/msg00085.html
* m4/error_h.m4 (gl_ERROR_H): Plant an alarm in case error infloops.
2026-04-13 14:02:16 -07:00
Paul Eggert
8b62743170 regex: omit unnecessary check_halt_state_context
* lib/regexec.c (prune_impossible_nodes):
Avoid unnecessary call to check_halt_state_context.
Suggested by Florian Weimer in:
https://sourceware.org/pipermail/libc-alpha/2026-April/176627.html
2026-04-13 13:27:29 -07:00
Bruno Haible
c754c51f0f regex: Fix use of uninitialized variable (regression yesterday).
Reported by Coverity.

* lib/regexec.c (re_search_internal): Move initialization of variable
'save_state_log' further up.
2026-04-13 17:15:25 +02:00
Jim Meyering
9774624062 regex: small simplification
* lib/regexec.c (re_search_internal): Use only one copy
of the 5-line reg-initialization code, removing that else block,
at the tiny cost of moving a small test into the loop.
2026-04-13 00:03:04 -07:00
Jim Meyering
eff1848fd4 regex: fix missed short match with backrefs
With a backref pattern like ^(.?)(.?).?\2\1 (no $), the engine
could miss valid short matches.  For example, "ab" should match
via all-empty groups, yet regexec returned no-match because
set_regs failed at the longest structural match (match_last=2)
and never retried at a shorter match_last.
* lib/regexec.c (re_search_internal): When set_regs fails for a
backref pattern, retry prune_impossible_nodes and set_regs at
progressively shorter match lengths.  Save a copy of state_log
before pruning so shorter retries can re-sift from the original
states.
* m4/regex.m4: Also reject system regex with this bug.
* tests/test-regex.c (main): Add a test for this bug.
Reported by Ed Morton in https://bugs.gnu.org/68725
Co-authored-by: Claude <noreply@anthropic.com>
2026-04-12 13:33:42 -07:00
Collin Funk
3db00ab434 doc: update documentation about fopen with the 'e' mode character
* doc/posix-functions/fopen.texi: Mention the 'e' mode character was
added in POSIX.1-2024 instead of a future revision.
2026-04-12 12:07:00 -07:00
Jim Meyering
8c22765403 regex: fix false match with backrefs and $ anchor
Use of sed or grep with both backreferences and an end-of-line
anchor could get false matches.  For example, this grep command
would falsely declare "ab" to be a palindrome:
  grep -E '^(.?)(.?).?\2\1$' <<< ab
In prune_impossible_nodes, falling back to a shorter match
skipped the halt-state context check, so $ was not verified.
* lib/regexec.c (prune_impossible_nodes): Also require
check_halt_state_context to succeed in the loop that searches
for an earlier halt state.
* m4/regex.m4: Bump serial to 82.  Reject any system regex
implementation with this bug.
* tests/test-regex.c (main): Add a test for this bug.
Reported by Ed Morton in https://bugs.gnu.org/68725
2026-04-12 11:33:55 -07:00
Paul Eggert
ed31e3616a tempname: call ‘clock’ only if !CLOCK_REALTIME
* lib/tempname.c (random_bits) [CLOCK_REALTIME]: Do not call
‘clock’, as an optimization.  There is no need to call ‘clock’, as
it likely gives us less info than clock_gettime, and if
clock_gettime fails then ‘clock’ will likely fail too.
This patch is a simplified version of the patch made in glibc commit
5f62cf88c4530c11904482775b7582bd7f6d80d2 dated 2024-09-25,
and Gnulib lib/tempname.c should now be suitable as-is for
replacing Glibc sysdeps/posix/tempname.c.
2026-04-11 14:07:00 -07:00
Paul Eggert
9bd5952ee9 doc: fix typos in previous doc patch 2026-04-11 13:29:07 -07:00
Paul Eggert
87fb310b69 doc: be more like POSIX in threading terms
In documentation and comments, be more like POSIX in terminology
involving multithreading.  Explain the distinction between
multithreaded process vs multithreaded program.  Change “program”
to “process” when the latter wording is more accurate or informative.
Simplify the wording for the constraints on processes that use
unlocked I/O.  Change “multithread-safe” to “thread-safe”.
Change “thread-safety” to “thread safety”.
However, do not change “multithreaded” to “multi-threaded” even
though there are some uses of both spellinga, as there are a whole
bunch of uses of “multithreaded”, also in identifier names;
perhaps Gnulib should even standardize on “multithreaded”
(not “multi-threaded”), contra POSIX.
2026-04-11 13:21:19 -07:00
Paul Eggert
fc2a05f786 sigprocmask: clarify GNULIB_SIGPROCMASK_SINGLE_THREAD doc 2026-04-11 09:37:09 -07:00
Bruno Haible
b84e952538 fenv-exceptions-trapping tests: Make test more debugging friendly.
Suggested by Pali Rohár <pali.rohar@gmail.com>.

* tests/test-fenv-except-trapping-1.c (main): Add an assertion.
2026-04-11 01:16:35 +02:00
Bruno Haible
20ce8b64ae sigprocmask: Allow single-thread optimization again.
* lib/sigprocmask.c (glwthread_spin_lock, glwthread_spin_unlock): Define
to empty if GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
(overrides_mt_lock, overrides_handler_lock): Don't define if
GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
* doc/multithread.texi (Multithreading Optimizations): Document
GNULIB_SIGPROCMASK_SINGLE_THREAD instead of
GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD.
2026-04-10 23:11:40 +02:00
Bruno Haible
a1a2837ec4 sigprocmask: Fix a signal-handler hang in case of a race condition.
* lib/sigprocmask.c (overrides_handler_lock): Renamed from
overrides_lock.
(overrides_mt_lock): New variable.
(pthread_sigmask): Lock both locks.
(rpl_signal): Lock overrides_mt_lock, not overrides_lock.
2026-04-10 22:57:04 +02:00
Bruno Haible
91b5ffbdd9 sigprocmask: Support multithreaded applications on native Windows.
* lib/signal.in.h (WIN_PTHREADS_SIGNAL_H): New macro.
* lib/sigprocmask.c: Include windows-spin.h.
(thread_local): New macro.
(blocked_set, pending_array): Mark as thread-local.
(blocked_handler): Remove function.
(struct override): New type.
(overrides, overrides_lock): New variables.
(override_handler): New function.
(pthread_sigmask): New function, borrowing from the previous sigprocmask
definition.
(sigprocmask): Now a wrapper around pthread_sigmask.
(rpl_signal): Use the overrides_lock to make it multithread-safe.
(_gl_raise_SIGPIPE): Add comments.
* modules/sigprocmask (Depends-on): Add windows-spin.
* lib/pthread_sigmask.c: Revert last change. On native Windows, don't
define pthread_sigmask here.
* modules/pthread_sigmask (Depends-on): Remove lock.
* NEWS: Remove the last entry.
2026-04-10 17:22:07 +02:00
Bruno Haible
1039a5f2ce stat: Update doc regarding mingw bug.
* doc/posix-functions/stat.texi: Update regarding mingw bug.
2026-04-06 13:38:22 +02:00
Bruno Haible
2c480fa522 mbrtowc, mbrtoc32: Silence -Wshadow warnings (regr. 2026-04-02).
Reported by Collin Funk.

* lib/mbrtowc.c (rpl_mbrtowc): Enclose the #include in a block.
* lib/mbrtoc32.c (mbrtoc32): Likewise.
2026-04-06 13:21:56 +02:00
Paul Eggert
0e049d12d8 sigprocmask: add NEWS entry 2026-04-05 15:20:39 -07:00
Paul Eggert
13d1e8d16c term-style-control: use pthread_sigmask
* lib/term-style-control.c (block_relevant_signals)
(unblock_relevant_signals): Prefer pthread_sigmask to sigprocmask.
* modules/term-style-control (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
2026-04-05 11:34:35 -07:00
Paul Eggert
a3a1e8974b fatal-signal: use pthread_sigmask
* lib/fatal-signal.c (block_fatal_signals)
(unblock_fatal_signals): Prefer pthread_sigmask to sigprocmask.
* modules/fatal-signal (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
2026-04-05 11:34:35 -07:00
Paul Eggert
1a914207cb sigaction: use pthread_sigmask
* lib/sigaction.c (sigaction_handler, sigaction):
Use pthread_sigmask, not sigprocmask.
* modules/sigaction (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
2026-04-05 11:34:34 -07:00
Paul Eggert
12a30be76f pthread_sigmask: lock here, not in sigprocmask
Since sigprocmask should now be used only in single-threaded processes,
move the locking from lib/sigprocmask.c to lib/pthread_sigmask.c.
* lib/pthread_sigmask.c: If !HAVE_SIGPROCMASK &&
!GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD, replace Gnulib sigprocmask
with a thread-safe subsitute sigprocmask_r.
Include glthread/lock.h to implement this.
* lib/sigprocmask.c (gl_lock_define_initialized, gl_lock_lock)
(gl_lock_unlock, sig_lock): Remove.  All uses removed.
Do not include glthread/lock.h.
* m4/signalblocking.m4 (gl_SIGNALBLOCKING):
Define HAVE_SIGPROCMASK, for the benefit of pthread_sigmask.c.
* modules/pthread_sigmask (Depends-on): Add ‘lock’.
* modules/sigprocmask (Depends-on): Remove ‘lock’.
2026-04-05 11:34:34 -07:00
Pádraig Brady
305e58f2f8 mcel: remove forced use of GLIBC's mbrtoc32
This is a performance win on GLIBC,
as tested on the coreutils multi-byte update to cut(1):

   $ yes $(yes éééááé | head -n9 | paste -s -d,) |
     head -n1M > mb.in

   $ time LC_ALL=C.UTF-8 src/cut-before -c1 mb.in >/dev/null
   real    0m1.582s

   $ time LC_ALL=C.UTF-8 src/cut-after -c1 mb.in >/dev/null
   real    0m0.592s

* lib/mcel.h: While GLIBC's mbrtoc32 is functional for mcel,
it is seen to be 2.6x slower than gnulib's implementation
due to GLIBC's per call locale handling.
2026-04-05 12:42:33 +01:00
Bruno Haible
3baee42d1a posix_spawn-internal: Remove a FIXME.
* lib/spawni.c (__spawni): Add comment regarding sigprocmask.
2026-04-04 23:17:59 +02:00
Bruno Haible
3582e674d3 linked-list-unportable-tests: Prefer pthread_sigmask over sigprocmask.
Suggested by Paul Eggert.

* tests/test-asyncsafe-linked_list-strong.c (block_sigint): Use
pthread_sigmask instead of sigprocmask.
* tests/test-asyncsafe-linked_list-weak.c (block_sigint): Likewise.
2026-04-04 22:55:34 +02:00
Bruno Haible
e4100b4078 asyncsafe-spin: Prefer pthread_sigmask over sigprocmask.
Suggested by Paul Eggert.

* lib/asyncsafe-spin.c (asyncsafe_spin_lock, asyncsafe_spin_unlock): Use
pthread_sigmask instead of sigprocmask.
* modules/asyncsafe-spin (Depends-on): Add pthread_sigmask. Remove
sigprocmask.
(Link): New section.
* modules/asyncsafe-spin-tests (Makefile.am): Link test-asyncsafe-spin1
with $(PTHREAD_SIGMASK_LIB).
* modules/jit/cache-tests (Makefile.am): Link test-cache with
$(PTHREAD_SIGMASK_LIB).
2026-04-04 22:44:10 +02:00
Bruno Haible
86fe27800e spawn-pipe: Prefer pthread_sigmask over sigprocmask.
Suggested by Paul Eggert.

* lib/spawn-pipe.c (execute): Use pthread_sigmask to get the set of
blocked signals.
* modules/spawn-pipe (Depends-on): Add pthread_sigmask.
2026-04-04 22:26:25 +02:00
Bruno Haible
e82e994cf8 execute: Prefer pthread_sigmask over sigprocmask.
Suggested by Paul Eggert.

* lib/execute.c (execute): Use pthread_sigmask to get the set of blocked
signals.
* modules/execute (Depends-on): Add pthread_sigmask.
2026-04-04 22:15:24 +02:00
Bruno Haible
f71c6b76aa sigpipe-die: Relax specification.
* lib/sigpipe-die.h (install_sigpipe_die_handler): Clarify how to use
this function in a multithreaded program.
2026-04-04 22:01:56 +02:00
Bruno Haible
ef8da50e22 pthread_sigmask: Make it usable without -lpthread on most platforms.
* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Define
PTHREAD_SIGMASK_LIB to empty, except on AIX. Define
PTHREAD_SIGMASK_NOT_IN_LIBC if a workaround is needed.
* lib/pthread_sigmask.c (pthread_sigmask): If
PTHREAD_SIGMASK_NOT_IN_LIBC, just use sigprocmask.
* doc/posix-functions/pthread_sigmask.texi: Mention the dropped link
requirement. Mention that the NetBSD 9 bug is fixed.
* doc/posix-functions/sigprocmask.texi: Update note relating to
pthread_sigmask.
2026-04-04 15:17:08 +02:00