| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the locale's positive_sign and negative_sign values would both be
returned by localeconv() as empty strings, strfmon() shall behave as if
the negative_sign value was the string "-".
This occurs with the C locale. The implementation previously assigned
"0" to sign_posn (parentheses around the entire string); now it assigns
it to "1" (sign before the string) when it is undefined (CHAR_MAX).
Austin Group Defect 1199[1] is applied, changing the requirements for
the '+' and '(' flags.
[1]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53913
(cherry picked from commit cf85e7034ad5640b18a3b68d6b291b7bf89bfc80)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to the Open Group Base Specifications Issue 8[1], strfmon(3)
should return EINVAL when the '+' flag was included in a conversion
specification and the locale's positive_sign and negative_sign values
would both be returned by localeconv(3) as empty strings.
Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53912
(cherry picked from commit 1fd018972a18b682521bb8f004dfd162327e5db2)
|
| |
|
|
|
|
| |
MFC after: 1 week
(cherry picked from commit 91e7f19ec4056587a85c1461a4f34a6d5d4b7b52)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As pointed out in the PR and the article linked below, the switch to
insertion sort in the BSD qsort code is based on a misunderstanding of
Knuth's TAOCP and is actually a pessimization. As demonstrated by the
added test, it is trivially easy to construct pathological input which
results in quadratic runtime. Without that misguided optimization, the
same input runs in nearly linearithmic time.
https://www.raygard.net/2022/02/26/Re-engineering-a-qsort-part-3
PR: 287089
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51907
(cherry picked from commit 5205b32de3fb7702e96b3991f5b1a61eee406d8b)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
science/dlib-cpp reveals an interesting scenario that works fine on
other platforms but not on FreeBSD; notably, it ends up creating a new
global object from some destructor which is called during
__cxa_finalize. This breaks when libdlib is dlopen()ed and then
subsequently dlclose()ed, as we never end up invoking the created
object's dtor until program exit when the shlib is already unmapped.
Fix it by noting when we're in the middle of __cxa_finalize for a dso,
and then restarting the search if __cxa_atexit() was called in the
middle somewhere.
We wait until we've processed the initial set before starting over and
processing the newly added handlers as if it were a complete set of
handlers added during runtime. The alternative is calling them as
they're added to maintain a LIFO in terms of total ordering, but in
theory a constructor could add another global object that also needs to
be destroyed, and that object needs to be destroyed after the one that
constructed it to avoid creating unexpected lifetime issues.
This manifests in the pdlib PHP extension for dlib crashing, see [0].
[0] https://github.com/goodspb/pdlib/issues/39
PR: 285870
Reviewed by: kevans (also supplied commit message)
(cherry picked from commit 23427c8e1fedb9fc68ad0bd27a59c7ffd2b3008c)
|
| |
|
|
|
|
| |
PR: 278701
(cherry picked from commit b27eb9ce96b838622e125fd969e8dc4914aabe18)
|
| |
|
|
| |
(cherry picked from commit 86e2bcbf47fb4c8dbd799f2f21c0ed338b2e8f1b)
|
| |
|
|
| |
(cherry picked from commit 56a0d5444d6f39302f3476b61c1b81ed39abe589)
|
| |
|
|
| |
(cherry picked from commit 6abee52e0d79f68fd725de748d7027ca8eef2294)
|
| |
|
|
| |
(cherry picked from commit 2a163c3649e59dd616e057994ec02092362f0ae7)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX has accepted a proposal[1] to add glibc-compatible ptsname_r. It
indicates an error by returning the error number, rather than returning
-1 and setting errno. Update RETURN VALUES in ptsname_r's man page now
to encourage folks to test that the return value != 0 rather than == -1.
[1] https://www.austingroupbugs.net/bug_view_page.php?bug_id=508
Reported by: Collin Funk
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42204
(cherry picked from commit a5ed6a815e38d6c622cd97a6020592ded579cf7a)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Compiler memory barriers do not prevent the CPU from executing the code
out of order. Switch to C11 atomics. This also lets us get rid of the
mutex; instead, loop until the compare_exchange succeeds.
While here, change the return value of at_quick_exit() on failure to
the more traditional -1, matching atexit().
Sponsored by: Klara, Inc.
Reviewed by: Olivier Certner, kevans, kib
Differential Revision: https://reviews.freebsd.org/D41936
(cherry picked from commit 1dc3abb052430279e47c8922d22b30922adcf0f6)
libc: Add a rudimentary test for quick_exit(3).
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D41937
(cherry picked from commit c7dd4601aeebbc1bbe131cbe6747476c124b47fe)
|
| |
|
|
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 7fde0187cc443468561f0a30d589ff0cfe45eef5)
(cherry picked from commit 560e22c8fe460e00d16e5268fe1fbb316ad81101)
(cherry picked from commit 5b5fa75acff11d871d0c90045f8c1a58fed85365)
|
| |
|
|
|
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b2c76c41be32)
|
| |
|
|
|
|
|
| |
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit fa9896e082a1)
|
| |
|
|
|
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit d0b2dbfa0ecf)
|
| |
|
|
|
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
Similar commit in main:
(cherry picked from commit 1d386b48a555)
|
| |
|
|
|
|
|
| |
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit 42b388439bd3)
|
| |
|
|
|
|
|
| |
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b3e7694832e8)
|
| |
|
|
|
|
|
|
|
|
|
| |
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix
(cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
|
| |
|
|
| |
(cherry picked from commit 0c6f0c0db75ea5a1e89a68a163fc555bdd7d00f5)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
When sorting, both the C11 standard (ISO/IEC 9899:2011, K.3.6.3.2) and
the ISO/IEC JTC1 SC22 WG14 N1172 standard, does not define objects of
zero size as undefined behaviour. However Microsoft's cpp-docs does.
Add proper checks for this. Found while working on bsort(3).
Reviewed by: kib@ and emaste@
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D39687
(cherry picked from commit 27bb0d337c0d82a1a4f310315840236eb239963c)
|
| |
|
|
|
|
|
|
|
|
|
| |
If there are less than two elements avoid executing the first
sorting loop. No functional change intended.
Reviewed by: kib@
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D39691
(cherry picked from commit ecb2ce3a51e9b09a57cd42262fc798ae089c0758)
|
| |
|
|
| |
(cherry picked from commit f5924ad8fde4d5e9c233b821cb6097c6a46740b5)
|
| |
|
|
| |
(cherry picked from commit 59cc636d94a6c9b28147304fa59351224f801e92)
|
| |
|
|
| |
(cherry picked from commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de)
|
| |
|
|
| |
(cherry picked from commit f0a15aafcb863f796e2a7f94d0fd8a857fb56103)
|
| |
|
|
| |
(cherry picked from commit 621bf91893ad96c2ec46e603bf4c5b8762e3f730)
|
| |
|
|
| |
(cherry picked from commit d96088b3ab5f5b833a78ff363f540cc5fa2c1e78)
|
| |
|
|
| |
(cherry picked from commit 7cfd67ce96d97c263c2c56c5c437426463467689)
|
| |
|
|
| |
(cherry picked from commit 0efec50e9e08f76e9e9d6a024763ca0fe83ae1f2)
|
| |
|
|
| |
(cherry picked from commit 34f88528edba44b2703ba8c772bef077eca33dab)
|
| |
|
|
| |
(cherry picked from commit 750fe3e6a4619e040c7b0951775698b61290102e)
|
| |
|
|
| |
(cherry picked from commit 947efadc3d6e778a824618d82f53f061bec69b77)
|
| |
|
|
| |
(cherry picked from commit 6da51e19e347c13e133bcba68cc6100c16320a01)
|
| |
|
|
| |
(cherry picked from commit 9e03b903e377c75a60cbbb89ed78955769a1c804)
|
| |
|
|
| |
(cherry picked from commit 0afd11d50f277c24e80dd0228b122bcc53d559c0)
|
| |
|
|
| |
(cherry picked from commit d5980dff6b512fa9ba08d6af3ff365805fed44fd)
|
| |
|
|
| |
(cherry picked from commit f81dfea2912dbc0560587ab534a3d8549dbbb95b)
|
| |
|
|
|
|
|
| |
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a8a43edc0f856167c483b554a89a868f53a6ce25)
|
| |
|
|
|
|
|
|
|
|
|
| |
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D34759
(cherry picked from commit 4b7f35db44cbf901e994fc9a4bcd4c98ebe8c4a1)
|
| |
|
|
|
|
| |
- s/peform/perform/
(cherry picked from commit 8dcf5860b369559ba176f5dc0d7ed278f8aecf38)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Mark Milliard has detected a case of undefined behavior with the LLVM
UBSAN. The mandoc program called qsort with a==NULL and n==0, which is
allowed by the POSIX standard. The qsort() in FreeBSD did not attempt
to perform any accesses using the passed pointer for n==0, but it did
add an offset to the pointer value, which is undefined behavior in
case of a NULL pointer. This operation has no adverse effects on any
achitecture supported by FreeBSD, but could be caught in more strict
environments.
After some discussion in the freebsd-current mail list, it was
concluded that the case of a==NULL and n!=0 should still be caught by
UBSAN (or cause a program abort due to an illegal access) in order to
not hide errors in programs incorrectly invoking qsort().
Only the the case of a==NULL and n==0 should be fixed to not perform
the undefined operation on a NULL pointer.
This commit makes qsort() exit before reaching the point of
potentially undefined behvior for the case n==0, but does not test
the value of a, since the result will not depend on whether this
pointer is NULL or an actual pointer to an array if n==0.
The issue found by Mark Milliard in the whatis command has been
reported to the upstream (OpenBSD) and has already been patched
there.
(cherry picked from commit d106f982a54cd299671ccad58bc456138a22ae7b)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Clang 13 produces the following warning for this function:
lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
^ ~~~~~~~~~
This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.
Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.
(cherry picked from commit 4e5d32a445f90d37966cd6de571978551654e3f3)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Before this patch there was a chance for thread that called rand(3)
slightly later to see rand3_state already allocated, but not yet
initialized. While this API is not expected to be thread-safe, it
is not expected to crash. ztest on 64-thread system reproduced it
reliably for me.
Submitted by: avg@
MFC after: 1 month
(cherry picked from commit 3a57f08b5042f15bb8ffb2fcce99d082d225d4cf)
|
| |
|
|
| |
(cherry picked from commit ee62fb2e1e14eab35d4e4e92535bcac9fc91eeb8)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This causes problems when using ASAN with a runtime older than 12.0 since
the intercept does not expect qsort() to call itself using an interposable
function call. This results in infinite recursion and stack exhaustion
when a binary compiled with -fsanitize=address calls qsort.
See also https://bugs.llvm.org/show_bug.cgi?id=46832 and
https://reviews.llvm.org/D84509 (ASAN runtime patch).
To prevent this problem, this patch uses a static helper function
for the actual qsort() implementation. This prevents interposition and
allows for direct calls. As a nice side-effect, we can also move the
qsort_s checks to the top-level function and out of the recursive calls.
Reviewed By: kib
Differential Revision: https://reviews.freebsd.org/D28133
(cherry picked from commit cbcfe28f9d5f975f97b7fb4a0d72bc9780eb0c46)
|
| |
|
|
|
|
|
|
|
| |
This file has other questionable code and "optimizations" (such as copying
one int at a time) that are probably no longer useful, so it might make
sense to replace it with a different implementation at some point.
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D28134
|
| |
|
|
|
|
| |
Define a non-const static char EMSG[] = "" to avoid having to add
__DECONST() to all uses of EMSG. Also make current_dash a const char *
to fix this warning.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings
MFC after: 1 month
Notes:
svn path=/head/; revision=368817
|