<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/thread, branch v1.1.19</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>store pthread stack guard sizes for pthread_getattr_np</title>
<updated>2018-02-03T15:04:24+00:00</updated>
<author>
<name>William Pitcock</name>
<email>nenolod@dereferenced.org</email>
</author>
<published>2018-02-02T20:08:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=7c709f2d4f9872d1b445f760b0e68da89e256b9e'/>
<id>7c709f2d4f9872d1b445f760b0e68da89e256b9e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>revise the definition of multiple basic locks in the code</title>
<updated>2018-01-09T18:15:27+00:00</updated>
<author>
<name>Jens Gustedt</name>
<email>Jens.Gustedt@inria.fr</email>
</author>
<published>2018-01-03T13:17:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=32482f61da7650ff10741bd5aedd66bbc3ea165b'/>
<id>32482f61da7650ff10741bd5aedd66bbc3ea165b</id>
<content type='text'>
In all cases this is just a change from two volatile int to one.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In all cases this is just a change from two volatile int to one.
</pre>
</div>
</content>
</entry>
<entry>
<title>consistently use the LOCK an UNLOCK macros</title>
<updated>2018-01-09T18:14:49+00:00</updated>
<author>
<name>Jens Gustedt</name>
<email>Jens.Gustedt@inria.fr</email>
</author>
<published>2018-01-03T13:17:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=c4bc0b1a64e1ef1e105df84401805a16e8dbe82a'/>
<id>c4bc0b1a64e1ef1e105df84401805a16e8dbe82a</id>
<content type='text'>
In some places there has been a direct usage of the functions. Use the
macros consistently everywhere, such that it might be easier later on to
capture the fast path directly inside the macro and only have the call
overhead on the slow path.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In some places there has been a direct usage of the functions. Use the
macros consistently everywhere, such that it might be easier later on to
capture the fast path directly inside the macro and only have the call
overhead on the slow path.
</pre>
</div>
</content>
</entry>
<entry>
<title>new lock algorithm with state and congestion count in one atomic int</title>
<updated>2018-01-09T18:10:12+00:00</updated>
<author>
<name>Jens Gustedt</name>
<email>Jens.Gustedt@inria.fr</email>
</author>
<published>2018-01-03T13:17:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=47d0bcd4762f223364e5b58d5a381aaa0cbd7c38'/>
<id>47d0bcd4762f223364e5b58d5a381aaa0cbd7c38</id>
<content type='text'>
A variant of this new lock algorithm has been presented at SAC'16, see
https://hal.inria.fr/hal-01304108. A full version of that paper is
available at https://hal.inria.fr/hal-01236734.

The main motivation of this is to improve on the safety of the basic lock
implementation in musl. This is achieved by squeezing a lock flag and a
congestion count (= threads inside the critical section) into a single
int. Thereby an unlock operation does exactly one memory
transfer (a_fetch_add) and never touches the value again, but still
detects if a waiter has to be woken up.

This is a fix of a use-after-free bug in pthread_detach that had
temporarily been patched. Therefore this patch also reverts

         c1e27367a9b26b9baac0f37a12349fc36567c8b6

This is also the only place where internal knowledge of the lock
algorithm is used.

The main price for the improved safety is a little bit larger code.

Under high congestion, the scheduling behavior will be different
compared to the previous algorithm. In that case, a successful
put-to-sleep may appear out of order compared to the arrival in the
critical section.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A variant of this new lock algorithm has been presented at SAC'16, see
https://hal.inria.fr/hal-01304108. A full version of that paper is
available at https://hal.inria.fr/hal-01236734.

The main motivation of this is to improve on the safety of the basic lock
implementation in musl. This is achieved by squeezing a lock flag and a
congestion count (= threads inside the critical section) into a single
int. Thereby an unlock operation does exactly one memory
transfer (a_fetch_add) and never touches the value again, but still
detects if a waiter has to be woken up.

This is a fix of a use-after-free bug in pthread_detach that had
temporarily been patched. Therefore this patch also reverts

         c1e27367a9b26b9baac0f37a12349fc36567c8b6

This is also the only place where internal knowledge of the lock
algorithm is used.

The main price for the improved safety is a little bit larger code.

Under high congestion, the scheduling behavior will be different
compared to the previous algorithm. In that case, a successful
put-to-sleep may appear out of order compared to the arrival in the
critical section.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix read-after-free type error in pthread_detach</title>
<updated>2017-10-14T03:00:34+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2017-10-14T03:00:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=c1e27367a9b26b9baac0f37a12349fc36567c8b6'/>
<id>c1e27367a9b26b9baac0f37a12349fc36567c8b6</id>
<content type='text'>
calling __unlock on t-&gt;exitlock is not valid because __unlock reads
the waiters count after making the atomic store that could allow
pthread_exit to continue and unmap the thread's stack and the object t
points to. for now, inline the __unlock logic with an unconditional
futex wake operation so that the waiters count is not needed.

once __lock/__unlock have been made safe for self-synchronized
destruction, we could switch back to using them.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
calling __unlock on t-&gt;exitlock is not valid because __unlock reads
the waiters count after making the atomic store that could allow
pthread_exit to continue and unmap the thread's stack and the object t
points to. for now, inline the __unlock logic with an unconditional
futex wake operation so that the waiters count is not needed.

once __lock/__unlock have been made safe for self-synchronized
destruction, we could switch back to using them.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix signal masking race in pthread_create with priority attributes</title>
<updated>2017-09-07T00:37:19+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2017-09-07T00:37:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=9e01be6e49b9ae433072207f420ef33c8189eb78'/>
<id>9e01be6e49b9ae433072207f420ef33c8189eb78</id>
<content type='text'>
if the parent thread was able to set the new thread's priority before
it reached the check for 'startlock', the new thread failed to restore
its signal mask and thus ran with all signals blocked.

concept for patch by Sergei, who reported the issue; unnecessary
changes were removed and comments added since the whole 'startlock'
thing is non-idiomatic and confusing. eventually it should be replaced
with use of idiomatic synchronization primitives.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
if the parent thread was able to set the new thread's priority before
it reached the check for 'startlock', the new thread failed to restore
its signal mask and thus ran with all signals blocked.

concept for patch by Sergei, who reported the issue; unnecessary
changes were removed and comments added since the whole 'startlock'
thing is non-idiomatic and confusing. eventually it should be replaced
with use of idiomatic synchronization primitives.
</pre>
</div>
</content>
</entry>
<entry>
<title>trap UB from attempts to join a detached thread</title>
<updated>2017-08-12T00:42:30+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2017-08-12T00:42:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=80bf5952551c002cf12d96deb145629765272db0'/>
<id>80bf5952551c002cf12d96deb145629765272db0</id>
<content type='text'>
passing to pthread_join the id of a thread which is not joinable
results in undefined behavior.

in principle the check to trap does not necessarily work if
pthread_detach was called after thread creation, since no effort is
made here to synchronize access to t-&gt;detached, but the check is
well-defined and harmless for callers which did not invoke UB, and
likely to help catch erroneous code that would otherwise mysteriously
hang.

patch by William Pitcock.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
passing to pthread_join the id of a thread which is not joinable
results in undefined behavior.

in principle the check to trap does not necessarily work if
pthread_detach was called after thread creation, since no effort is
made here to synchronize access to t-&gt;detached, but the check is
well-defined and harmless for callers which did not invoke UB, and
likely to help catch erroneous code that would otherwise mysteriously
hang.

patch by William Pitcock.
</pre>
</div>
</content>
</entry>
<entry>
<title>unify the use of FUTEX_PRIVATE</title>
<updated>2017-07-04T21:12:52+00:00</updated>
<author>
<name>Jens Gustedt</name>
<email>Jens.Gustedt@inria.fr</email>
</author>
<published>2017-06-24T08:18:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=d906fa3118c888227d858b6d642a09e055eca2b4'/>
<id>d906fa3118c888227d858b6d642a09e055eca2b4</id>
<content type='text'>
The flag 1&lt;&lt;7 is used in several places for different purposes that are
not always easy to distinguish. Mark those usages that correspond to the
flag that is used by the kernel for futexes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The flag 1&lt;&lt;7 is used in several places for different purposes that are
not always easy to distinguish. Mark those usages that correspond to the
flag that is used by the kernel for futexes.
</pre>
</div>
</content>
</entry>
<entry>
<title>use hard-coded sh4a atomic opcodes to avoid linker errors on sh</title>
<updated>2017-06-08T23:44:27+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2017-06-08T23:44:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=bc313e880c6cde2e512d2f43e84968d1b12bd19d'/>
<id>bc313e880c6cde2e512d2f43e84968d1b12bd19d</id>
<content type='text'>
when using the sh4a opcodes, the assembler tags the resulting object
file as requiring sh4a. the linker then refuses to (static) link it
with object files marked as requiring j2, since there is no isa level
that includes both sh4a and j2 instructions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
when using the sh4a opcodes, the assembler tags the resulting object
file as requiring sh4a. the linker then refuses to (static) link it
with object files marked as requiring j2, since there is no isa level
that includes both sh4a and j2 instructions.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix build regression in arm atomics asm with new binutils</title>
<updated>2017-02-15T22:50:47+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2017-02-15T22:05:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=b261a24256792177a5f0531dbb25cc6267220ca5'/>
<id>b261a24256792177a5f0531dbb25cc6267220ca5</id>
<content type='text'>
binutils commit bada43421274615d0d5f629a61a60b7daa71bc15 tightened
immediate fixup handling in gas in such a way that the final .arch of
an object file must be compatible with the fixups used when the
instruction was assembled; this in turn broke assembling of atomics.s,
at least in thumb mode.

it's not clear whether this should be considered a bug in gas, but
.object_arch is preferable anyway for our purpose here of controlling
the ISA level tag on the object file being produced, and it's the
intended directive for use in object files with runtime code
selection. research by Szabolcs Nagy confirmed that .object_arch is
supported in all relevant versions of binutils and clang's integrated
assembler.

patch by Reiner Herrmann.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
binutils commit bada43421274615d0d5f629a61a60b7daa71bc15 tightened
immediate fixup handling in gas in such a way that the final .arch of
an object file must be compatible with the fixups used when the
instruction was assembled; this in turn broke assembling of atomics.s,
at least in thumb mode.

it's not clear whether this should be considered a bug in gas, but
.object_arch is preferable anyway for our purpose here of controlling
the ISA level tag on the object file being produced, and it's the
intended directive for use in object files with runtime code
selection. research by Szabolcs Nagy confirmed that .object_arch is
supported in all relevant versions of binutils and clang's integrated
assembler.

patch by Reiner Herrmann.
</pre>
</div>
</content>
</entry>
</feed>
