<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/internal, branch master</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>strtod: fix incorrect logic detecting underflow</title>
<updated>2026-10-12T20:26:45+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-10-12T20:26:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=6426a515e042f32cb9f1d82ec9d0905e0c500d6c'/>
<id>6426a515e042f32cb9f1d82ec9d0905e0c500d6c</id>
<content type='text'>
underflow should be reported (via ERANGE) on any inexact denormal
result, which is expressed in the logic as (denormal &amp;&amp; frac). the
denormal boolean is set above based on the magnitude of the exponent
relative to the target type's exponent range after normalizing the
working mantissa to occupy LDBL_MANT_DIG bits directly above the radix
point. but, since rounding up can raise the exponent out of the
denormal range, there is additional logic to clear the denormal flag
when that happens, and it was wrong.

the logic clearing denormal triggered when:

    bits==LDBL_MANT_DIG+e2-emin

here e2+LDBL_MANT_DIG is the actual place of the highest bit, and
initially, bits+emin was equal to -emax+3. however, at the point the
condition is evaluated, bits no longer represents the full mantissa
width of the target type. it has already been replaced with a reduced
width corresponding to the precision of the denormal. as a consequence
of the replacement, the condition was basically always true (except
when bits gets clamped non-negative), and so the denormal flag got
cleared when rounding up with carry.

the logic is fixed by using the value -emax+3 which is constant for
the duration of the function, and by moving evaluation from before the
exponent adjust to after, since the denormal flag should be cleared
based on the new exponent, not the old exponent.

with this change, behavior has been confirmed to be correct for
rounding both up and down around the minimum normal and maximum
denormal double, expressed both as 21 decimal digits and the full
exact value.

this patch does not address missing underflow logic when parsing hex
floats, which is a separate issue.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
underflow should be reported (via ERANGE) on any inexact denormal
result, which is expressed in the logic as (denormal &amp;&amp; frac). the
denormal boolean is set above based on the magnitude of the exponent
relative to the target type's exponent range after normalizing the
working mantissa to occupy LDBL_MANT_DIG bits directly above the radix
point. but, since rounding up can raise the exponent out of the
denormal range, there is additional logic to clear the denormal flag
when that happens, and it was wrong.

the logic clearing denormal triggered when:

    bits==LDBL_MANT_DIG+e2-emin

here e2+LDBL_MANT_DIG is the actual place of the highest bit, and
initially, bits+emin was equal to -emax+3. however, at the point the
condition is evaluated, bits no longer represents the full mantissa
width of the target type. it has already been replaced with a reduced
width corresponding to the precision of the denormal. as a consequence
of the replacement, the condition was basically always true (except
when bits gets clamped non-negative), and so the denormal flag got
cleared when rounding up with carry.

the logic is fixed by using the value -emax+3 which is constant for
the duration of the function, and by moving evaluation from before the
exponent adjust to after, since the denormal flag should be cleared
based on the new exponent, not the old exponent.

with this change, behavior has been confirmed to be correct for
rounding both up and down around the minimum normal and maximum
denormal double, expressed both as 21 decimal digits and the full
exact value.

this patch does not address missing underflow logic when parsing hex
floats, which is a separate issue.
</pre>
</div>
</content>
</entry>
<entry>
<title>floatscan: fix oob store at -1 index in mantissa buffer at wrap</title>
<updated>2026-09-22T19:36:08+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-09-22T19:36:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=dd856098ad76451718161f864158a38157d8b871'/>
<id>dd856098ad76451718161f864158a38157d8b871</id>
<content type='text'>
the code to implement a modular postincrement was too clever, and
essentially did it as a reducing version of (z+=1)-1, but only applied
the redution after the addition not the subtraction. as a result, it
evaluated to -1 when wrapping, causing a fixed value of zero to be
stored out of bounds below the buffer.

whether this condition is triggered depends on where the mantissa bits
end up in the circular buffer after processing.

for archs with 80-bit extended long double or IEEE quad long double,
the input "710542735760100185871124267578125e-33" was reported to and
has been confirmed to trigger it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the code to implement a modular postincrement was too clever, and
essentially did it as a reducing version of (z+=1)-1, but only applied
the redution after the addition not the subtraction. as a result, it
evaluated to -1 when wrapping, causing a fixed value of zero to be
stored out of bounds below the buffer.

whether this condition is triggered depends on where the mantissa bits
end up in the circular buffer after processing.

for archs with 80-bit extended long double or IEEE quad long double,
the input "710542735760100185871124267578125e-33" was reported to and
has been confirmed to trigger it.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix rounding of hex floats in strtod/scanf on ld64 and ld128 archs</title>
<updated>2026-05-21T13:37:18+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2026-05-21T13:37:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=50979c5bc89a7b02023e5c0a5ea1ca4da8616a91'/>
<id>50979c5bc89a7b02023e5c0a5ea1ca4da8616a91</id>
<content type='text'>
the expression LDBL_MANT_DIG/4+1 was intended to represent the number
of hex digits which can be significant, after which all that matters
to the result, regardless of rounding mode, is whether any part of the
tail is nonzero.

however, the expression LDBL_MANT_DIG/4 is only exact for ld80 archs.
for ld64 and ld128, the truncation of the remainder caused one too few
digits to be processed, producing incorrect rounding.

for ld128 archs, only strtold and scanf's %La conversion specifier
were affected; doubles and floats still had plenty of trailing digits
to yield a correct final rounding. but for ld64 archs, the number of
digits processed were insufficient for double, and could affect any
code using strtod or scanf's %a.

for ld64 archs, 0x1.111111111111281 produces an incorrect rounding
down, and 0x1.11111111111111 produces an incorrect rounding up.

for ld128 archs, the inputs 0x1.111111111111111111111111111281 and
0x1.11111111111111111111111111111 behave respectively.

rounding up in the expression for the number of hex digits needed
produces correct results.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the expression LDBL_MANT_DIG/4+1 was intended to represent the number
of hex digits which can be significant, after which all that matters
to the result, regardless of rounding mode, is whether any part of the
tail is nonzero.

however, the expression LDBL_MANT_DIG/4 is only exact for ld80 archs.
for ld64 and ld128, the truncation of the remainder caused one too few
digits to be processed, producing incorrect rounding.

for ld128 archs, only strtold and scanf's %La conversion specifier
were affected; doubles and floats still had plenty of trailing digits
to yield a correct final rounding. but for ld64 archs, the number of
digits processed were insufficient for double, and could affect any
code using strtod or scanf's %a.

for ld64 archs, 0x1.111111111111281 produces an incorrect rounding
down, and 0x1.11111111111111 produces an incorrect rounding up.

for ld128 archs, the inputs 0x1.111111111111111111111111111281 and
0x1.11111111111111111111111111111 behave respectively.

rounding up in the expression for the number of hex digits needed
produces correct results.
</pre>
</div>
</content>
</entry>
<entry>
<title>vdso: add support for GNU hash tables</title>
<updated>2026-03-19T13:57:35+00:00</updated>
<author>
<name>Tomáš Hulata</name>
<email>hulata@sysart.tech</email>
</author>
<published>2025-08-22T22:54:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=1347154cdc5c18518383ad64dda5531aedac6020'/>
<id>1347154cdc5c18518383ad64dda5531aedac6020</id>
<content type='text'>
on some kernel builds, the vdso exports symbols with DT_GNU_HASH but
omits DT_HASH, causing the vdso not to get used and for clock_gettime
to fall back to using a syscall.

our vdso resolver does not use the hash table anyway, but does need
the symbol count from the standard sysv hash table. if it's missing,
use the GNU hashtable to calculate the number of symbols.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
on some kernel builds, the vdso exports symbols with DT_GNU_HASH but
omits DT_HASH, causing the vdso not to get used and for clock_gettime
to fall back to using a syscall.

our vdso resolver does not use the hash table anyway, but does need
the symbol count from the standard sysv hash table. if it's missing,
use the GNU hashtable to calculate the number of symbols.
</pre>
</div>
</content>
</entry>
<entry>
<title>abstract missing SYS_pause syscall with macros</title>
<updated>2024-10-10T21:11:39+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2024-10-10T21:09:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=6d8000d3c6e1026415f8398f540f5f3783622538'/>
<id>6d8000d3c6e1026415f8398f540f5f3783622538</id>
<content type='text'>
newer archs lack the syscall. the pause() function accounted for this
with its own #ifdef, but that didn't allow use of the syscall directly
elsewhere, so move the logic to macros in src/internal/syscall.h where
it can be shared.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
newer archs lack the syscall. the pause() function accounted for this
with its own #ifdef, but that didn't allow use of the syscall directly
elsewhere, so move the logic to macros in src/internal/syscall.h where
it can be shared.
</pre>
</div>
</content>
</entry>
<entry>
<title>add missing inline keyword on default a_barrier definition</title>
<updated>2024-03-02T17:34:05+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2024-03-02T17:34:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=fd7d018521115f2674bf85cbccaf745852b9ed3a'/>
<id>fd7d018521115f2674bf85cbccaf745852b9ed3a</id>
<content type='text'>
this is not needed, but may act as a hint to the compiler, and also
serves to suppress unused function warnings if enabled (on by default
since commit 86ac0f794731f03dfff40ee843ff9e2752945d5e).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this is not needed, but may act as a hint to the compiler, and also
serves to suppress unused function warnings if enabled (on by default
since commit 86ac0f794731f03dfff40ee843ff9e2752945d5e).
</pre>
</div>
</content>
</entry>
<entry>
<title>add framework to support archs without a native wait4 syscall</title>
<updated>2024-02-22T23:50:34+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2024-02-22T23:50:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=19563e1850808af216b1b84263bb7e83cccce506'/>
<id>19563e1850808af216b1b84263bb7e83cccce506</id>
<content type='text'>
this commit should make no codegen change for existing archs, but is a
prerequisite for new archs including riscv32. the wait4 emulation
backend provides both cancellable and non-cancellable variants because
waitpid is required to be a cancellation point, but all of our other
uses are not, and most of them cannot be.

based on patch by Stefan O'Rear.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this commit should make no codegen change for existing archs, but is a
prerequisite for new archs including riscv32. the wait4 emulation
backend provides both cancellable and non-cancellable variants because
waitpid is required to be a cancellation point, but all of our other
uses are not, and most of them cannot be.

based on patch by Stefan O'Rear.
</pre>
</div>
</content>
</entry>
<entry>
<title>ldso: convert TLSDESC_BACKWARDS from "#ifdef" to "if" logic</title>
<updated>2023-11-07T02:48:02+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2023-11-07T02:48:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=039d3c34f2e3578a8b7ada42f89213b844aa7a4e'/>
<id>039d3c34f2e3578a8b7ada42f89213b844aa7a4e</id>
<content type='text'>
this style is preferred because it allows the code to be
compile-checked even on archs where it is not used.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this style is preferred because it allows the code to be
compile-checked even on archs where it is not used.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix public clone function to be safe and usable by applications</title>
<updated>2023-06-01T20:15:38+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2023-05-31T16:04:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=fa4a8abd06a401822cc8ba4e352a219544c0118d'/>
<id>fa4a8abd06a401822cc8ba4e352a219544c0118d</id>
<content type='text'>
the clone() function has been effectively unusable since it was added,
due to producing a child process with inconsistent state. in
particular, the child process's thread structure still contains the
tid, thread list pointers, thread count, and robust list for the
parent. this will cause malfunction in interfaces that attempt to use
the tid or thread list, some of which are specified to be
async-signal-safe.

this patch attempts to make clone() consistent in a _Fork-like sense.
as in _Fork, when the parent process is multi-threaded, the child
process inherits an async-signal context where it cannot call
AS-unsafe functions, but its context is now intended to be safe for
calling AS-safe functions. making clone fork-like would also be a
future option, if it turns out that this is what makes sense to
applications, but it's not done at this time because the changes would
be more invasive.

in the case where the CLONE_VM flag is used, clone is only vfork-like,
not _Fork-like. in particular, the child will see itself as having the
parent's tid, and cannot safely call any libc functions but one of the
exec family or _exit.

handling of flags and variadic arguments is also changed so that
arguments are only consumed with flags that indicate their presence,
and so that flags which produce an inconsistent state are disallowed
(reported as EINVAL). in particular, all libc functions carry a
contract that they are only callable with ABI requirements met, which
includes having a valid thread pointer to a thread structure that's
unique within the process, and whose contents are opaque and only able
to be setup internally by the implementation. the only way for an
application to use flags that violate these requirements without
executing any libc code is to perform the syscall from
application-provided asm.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the clone() function has been effectively unusable since it was added,
due to producing a child process with inconsistent state. in
particular, the child process's thread structure still contains the
tid, thread list pointers, thread count, and robust list for the
parent. this will cause malfunction in interfaces that attempt to use
the tid or thread list, some of which are specified to be
async-signal-safe.

this patch attempts to make clone() consistent in a _Fork-like sense.
as in _Fork, when the parent process is multi-threaded, the child
process inherits an async-signal context where it cannot call
AS-unsafe functions, but its context is now intended to be safe for
calling AS-safe functions. making clone fork-like would also be a
future option, if it turns out that this is what makes sense to
applications, but it's not done at this time because the changes would
be more invasive.

in the case where the CLONE_VM flag is used, clone is only vfork-like,
not _Fork-like. in particular, the child will see itself as having the
parent's tid, and cannot safely call any libc functions but one of the
exec family or _exit.

handling of flags and variadic arguments is also changed so that
arguments are only consumed with flags that indicate their presence,
and so that flags which produce an inconsistent state are disallowed
(reported as EINVAL). in particular, all libc functions carry a
contract that they are only callable with ABI requirements met, which
includes having a valid thread pointer to a thread structure that's
unique within the process, and whose contents are opaque and only able
to be setup internally by the implementation. the only way for an
application to use flags that violate these requirements without
executing any libc code is to perform the syscall from
application-provided asm.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix wrong sigaction syscall ABI on mips*, or1k, microblaze, riscv64</title>
<updated>2023-02-09T17:33:35+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2023-02-09T16:52:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=269d193820342dc109f39909d78fb30f4c978f76'/>
<id>269d193820342dc109f39909d78fb30f4c978f76</id>
<content type='text'>
we wrongly defined a dummy SA_RESTORER flag on these archs, despite
the kernel interface not actually having such a feature. on archs
which lack SA_RESTORER, the kernel sigaction structure also lacks the
restorer function pointer member, which means the signal mask appears
at a different offset. the kernel was thereby interpreting the bits of
the code address as part of the signal set to be masked while handling
the signal.

this patch removes the erroneous SA_RESTORER definitions from archs
which do not have it, makes access to the member conditional on
whether SA_RESTORER is defined for the arch, and removes the
now-unused asm for the affected archs.

because there are reportedly versions of qemu-user which also use the
wrong ABI here, the old ksigaction struct size is preserved with an
unused member at the end. this is harmless and mitigates the risk of
such a bug turning into a buffer overflow onto the sigaction
function's stack.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
we wrongly defined a dummy SA_RESTORER flag on these archs, despite
the kernel interface not actually having such a feature. on archs
which lack SA_RESTORER, the kernel sigaction structure also lacks the
restorer function pointer member, which means the signal mask appears
at a different offset. the kernel was thereby interpreting the bits of
the code address as part of the signal set to be masked while handling
the signal.

this patch removes the erroneous SA_RESTORER definitions from archs
which do not have it, makes access to the member conditional on
whether SA_RESTORER is defined for the arch, and removes the
now-unused asm for the affected archs.

because there are reportedly versions of qemu-user which also use the
wrong ABI here, the old ksigaction struct size is preserved with an
unused member at the end. this is harmless and mitigates the risk of
such a bug turning into a buffer overflow onto the sigaction
function's stack.
</pre>
</div>
</content>
</entry>
</feed>
