Skip to content

[Problem]: SIGFPE (divide by zero) in rtp_buffered_audio_processor when conn->input_rate is still 0 (ap2_buffered_audio_processor.c:668) #2251

Description

@aronvandepol

What happened?

Shairport Sync 5.0.4 (Arch Linux package, AirPlay 2 build) crashes with SIGFPE (integer divide by zero) a few seconds after an AirPlay 2 buffered session starts. It has happened six times on this machine since 2026-07-31, most often on the first AirPlay 2 connection after boot (twice at ~75 s of service uptime). systemd restarts the service and the next connection usually works.

I symbolized the core with debuginfod. The crashing thread is ap2_bat_1 (rtp_buffered_audio_processor) at ap2_buffered_audio_processor.c:668:

usleep(((1000000 * conn->frames_per_packet) / conn->input_rate) * 2); // wait for approximately the length of two packets

Registers at the fault: rax = 352000000 (= 1000000 * 352, so frames_per_packet was already 352) and the divisor conn->input_rate was 0 (si_code = FPE_INTDIV).

My reading of the source (please correct me): for buffered streams conn->input_rate is only assigned in player.c (conn->input_rate = get_ssrc_rate(ssrc)) once the first audio block is decoded, whereas frames_per_packet comes earlier from the SETUP plist. If the "no block ready yet, wait" branch at line 668 runs before the first block has been decoded, the divisor is still the zero left from the connection's memset. player.c already has an if (conn->input_rate == 0) debug(1, "input rate not set!") guard for the same field, but this division has none. The same line is still present unguarded on the development branch (currently line 689).

Expected: no crash. A minimal guard fixes it for me (running it locally now):

uint32_t wait_rate = conn->input_rate;
if (wait_rate == 0)
  wait_rate = 44100;
usleep(((1000000 * conn->frames_per_packet) / wait_rate) * 2);

Issue #2210 reports the same signal (SIGFPE, AirPlay 2, user service, PipeWire) after sleep/wake, and was closed as stale. In my case the machine had just booted, not woken from sleep, so I don't think sleep is the trigger there either.

Relevant log output

Aug 15 18:18:29.484517 arch systemd[1342]: Started Shairport Sync AirPlay receiver (user session).
Aug 15 18:18:31.268735 arch shairport-sync[1522]: warning: could not acquire a Shairport Sync native D-Bus interface "org.gnome.ShairportSync" on the system bus.
Aug 15 18:18:31.269035 arch shairport-sync[1522]: warning: could not acquire an MPRIS interface named "org.mpris.MediaPlayer2.ShairportSync" on the system bus.
Aug 15 18:19:39.894868 arch shairport-sync[1522]: Can not set realtime properties of a thread.
Aug 15 18:19:46.954360 arch systemd-coredump[17513]: Process 1522 (convolver) of user 1000 dumped core.
Aug 15 18:19:46.985204 arch systemd[1342]: shairport-sync.service: Main process exited, code=dumped, status=8/FPE

coredumpctl info:
           PID: 1522 (convolver)
           TID: 16529 (ap2_bat_1)
        Signal: 8 (FPE) si_code: FPE_INTDIV
  Command Line: /usr/bin/shairport-sync -c /home/aron/.config/shairport-sync/shairport-sync.conf

gdb (with debuginfod symbols):
Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x000055ab580f0e21 in rtp_buffered_audio_processor (arg=0x7f64900066e0) at /usr/src/debug/shairport-sync/shairport-sync-5.0.4/ap2_buffered_audio_processor.c:668
668	          usleep(((1000000 * conn->frames_per_packet) / conn->input_rate) * 2); // wait for approximately the length of two packets
#1  0x00007f64e8e980a2 in start_thread (arg=<optimized out>) at pthread_create.c:454
#2  0x00007f64e8f2080c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
   0x55ab580f0e15 <rtp_buffered_audio_processor+3173>:	imul   $0xf4240,0x12240(%rbx),%eax
   0x55ab580f0e1f <rtp_buffered_audio_processor+3183>:	xor    %edx,%edx
=> 0x55ab580f0e21 <rtp_buffered_audio_processor+3185>:	divl   0x12250(%rbx)
rax            0x14fb1800          352000000
rdx            0x0                 0

Crash history (all SIGFPE unless noted):
Sun 2026-07-19 18:26:48 CEST SIGABRT
Fri 2026-07-31 15:00:10 CEST SIGFPE
Fri 2026-07-31 15:16:57 CEST SIGFPE
Wed 2026-08-12 15:06:26 CEST SIGFPE (package 5.0.4-2)
Wed 2026-08-12 15:09:11 CEST SIGFPE
Wed 2026-08-12 15:12:22 CEST SIGFPE
Sat 2026-08-15 18:19:46 CEST SIGFPE (package 5.0.4-3)

System Information.

Desktop PC, Intel Core i9-9900K, Arch Linux (Omarchy), kernel 7.1.8-arch1-3, PipeWire 1.6.8 (pipewire-pulse), output_backend = "pulseaudio". Sender: iPhone. Running as a systemd user service.

Configuration Information.

Linux arch 7.1.8-arch1-3 #1 SMP PREEMPT_DYNAMIC Tue, 11 Aug 2026 09:16:08 +0000 x86_64 GNU/Linux

5.0.4-AirPlay2-smi10-OpenSSL-Avahi-dns_sd-ALSA-jack-PulseAudio-PipeWire-stdout-pipe-soxr-convolution-metadata-mqtt-dbus-mpris-sysconfdir:/etc

Config (non-default):

output_backend = "pulseaudio"; port = 5000; udp_port_base = 6001; udp_port_range = 10; allow_session_interruption = "yes"; log_verbosity = 0.

PulseAudio or PipeWire installed?

  • Yes (PipeWire with pipewire-pulse)

How did you install Shairport Sync?

Distribution package (Arch Linux shairport-sync 5.0.4-3, built with --with-airplay-2).

Check previous issues

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions