pipewire/spa/plugins/support
Arun Raghavan f11ab0da3e spa: loop: Mark cancellation fields as volatile
Cancellation handlers use setjmp/longjmp, for which the C99
specification has the following note:

> 17.3.2.1 (3)
> All accessible objects have values, and all other components of the
> abstract machine) have state, as of the time the longjmp function was
> called, except that the values of objects of automatic storage
> duration that are local to the function containing the invocation of
> the corresponding setjmp macro that do not have volatile-qualified
> type and have been changed between the setjmp invocation and longjmp
> call are indeterminate.

While everything works fine with GCC, with Clang we see that the
cancellation handler doesn't seem to have an effect (loop-test fails
when it notices that its spa_source's priv and mask have not been
cleaned up).

The underlying cause is that the compiler can assume data.ep_count is
only used in loop_iterate_cancel(), and so can be cached in a register.
When we access that field in the cancellation handler, it was never
actually written to the memory on the stack, so the read in
cancellation_handler() does not see the current value.

We fix this by marking all fields on the stack that we expect to be
modified in loop_iterate_cancel() as volatile, forcing the memory to be
updated and correctly available to the cancellation handler.
2026-03-12 09:24:53 +00:00
..
cpu-arm.c treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00
cpu-riscv.c spa/support: implement RISCV V CPU detection 2024-09-18 10:40:48 +00:00
cpu-x86.c treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00
cpu.c spa: support: use feature macro from config.h 2024-09-18 22:29:11 +02:00
dbus.c support: return NULL instead of FALSE 2026-01-03 22:54:25 +01:00
evl-plugin.c spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
evl-system.c spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
journal.c journal: prepend code location to messages at debug log levels 2024-04-28 16:02:28 +03:00
logger.c treewide: fix some -Wdiscarded-qualifiers 2026-02-19 21:00:10 +01:00
loop.c spa: loop: Mark cancellation fields as volatile 2026-03-12 09:24:53 +00:00
meson.build meson: Search for and link to stdthreads 2024-09-23 08:09:45 +00:00
node-driver.c spa: node-driver: Expose the clock id as param properties 2025-10-28 07:18:59 +00:00
null-audio-sink.c modules: support audio.layout where we can 2025-10-30 12:29:31 +01:00
plugin.c spa: export log topic enumerations 2024-01-04 10:02:55 +00:00
system.c pipewire-alsa: Propagate errors from eventfd(). 2024-02-19 14:16:26 +00:00