News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[fluidsynth] Bug when changing music tracks (MIDI)

Started by Yona-TYT, January 13, 2026, 01:27:07 AM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

Yona-TYT


I previously reported a persistent bug that occurs when changing music tracks. I've confirmed that it's still present, but unfortunately, the debugging information isn't very helpful.

I'm using Linux and r11858

Screenshot_2026-01-12_21-26-40.png

(gdb) run
Starting program: /home/yona/Games/simutrans-nigth/simutrans
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffede276c0 (LWP 9331)]
[New Thread 0x7fffed4e56c0 (LWP 9332)]
[New Thread 0x7fffecce46c0 (LWP 9333)]
[New Thread 0x7fffec4e36c0 (LWP 9334)]
[New Thread 0x7fffebce26c0 (LWP 9335)]
[New Thread 0x7fffeb4e16c0 (LWP 9336)]
[New Thread 0x7fffeace06c0 (LWP 9337)]
[New Thread 0x7fffea4df6c0 (LWP 9338)]
[New Thread 0x7fffe9cde6c0 (LWP 9339)]
[New Thread 0x7fffe940e6c0 (LWP 9340)]
[Thread 0x7fffe940e6c0 (LWP 9340) exited]
[Thread 0x7fffe9cde6c0 (LWP 9339) exited]
[Thread 0x7fffea4df6c0 (LWP 9338) exited]
[New Thread 0x7fffea4df6c0 (LWP 9341)]
[New Thread 0x7fffe9cde6c0 (LWP 9342)]
[New Thread 0x7fffe940e6c0 (LWP 9343)]
[New Thread 0x7fffdbe226c0 (LWP 9346)]
[New Thread 0x7fffd76216c0 (LWP 9347)]
[New Thread 0x7fffd6e206c0 (LWP 9348)]
[New Thread 0x7fffd62046c0 (LWP 9350)]
[New Thread 0x7fffd5a036c0 (LWP 9351)]
[New Thread 0x7fffd52026c0 (LWP 9352)]
[New Thread 0x7fffd4a016c0 (LWP 9353)]
[New Thread 0x7fffbbfff6c0 (LWP 9354)]
[New Thread 0x7fffbb7fe6c0 (LWP 9355)]
[New Thread 0x7fffbaffd6c0 (LWP 9356)]
[New Thread 0x7fffba7fc6c0 (LWP 9357)]
[New Thread 0x7fffb9ffb6c0 (LWP 9358)]
[New Thread 0x7fffb97fa6c0 (LWP 9359)]
[New Thread 0x7fffb8ff96c0 (LWP 9360)]
[New Thread 0x7fffa0a7c6c0 (LWP 9361)]
[New Thread 0x7fff9a17a6c0 (LWP 9362)]
script engine started.
[New Thread 0x7fff999796c0 (LWP 9363)]
[Thread 0x7fff999796c0 (LWP 9363) exited]
[Thread 0x7fffe940e6c0 (LWP 9343) exited]
[Thread 0x7fffe9cde6c0 (LWP 9342) exited]
[Thread 0x7fffea4df6c0 (LWP 9341) exited]
[New Thread 0x7fffea4df6c0 (LWP 9364)]
[New Thread 0x7fffe9cde6c0 (LWP 9365)]
[New Thread 0x7fffe940e6c0 (LWP 9366)]
[New Thread 0x7fff999796c0 (LWP 9367)]
[New Thread 0x7fff991786c0 (LWP 9369)]
script engine started.
[Thread 0x7fff991786c0 (LWP 9369) exited]
[New Thread 0x7fff991786c0 (LWP 9370)]
[Thread 0x7fff991786c0 (LWP 9370) exited]
[New Thread 0x7fff991786c0 (LWP 9373)]
[Thread 0x7fff991786c0 (LWP 9373) exited]
script engine started.
[New Thread 0x7fff991786c0 (LWP 9378)]
[Thread 0x7fff991786c0 (LWP 9378) exited]
[New Thread 0x7fff991786c0 (LWP 9530)]
script engine started.
[Thread 0x7fff991786c0 (LWP 9530) exited]
[New Thread 0x7fff991786c0 (LWP 9531)]
[Thread 0x7fff991786c0 (LWP 9531) exited]
[New Thread 0x7fff991786c0 (LWP 9545)]
script engine started.
[Thread 0x7fff991786c0 (LWP 9545) exited]
[New Thread 0x7fff991786c0 (LWP 9546)]
[Thread 0x7fff991786c0 (LWP 9546) exited]
[New Thread 0x7fff991786c0 (LWP 9549)]
script engine started.
[Thread 0x7fff991786c0 (LWP 9549) exited]
[New Thread 0x7fff991786c0 (LWP 9550)]
[Thread 0x7fff991786c0 (LWP 9550) exited]
[New Thread 0x7fff991786c0 (LWP 9561)]
[Thread 0x7fff991786c0 (LWP 9561) exited]
[New Thread 0x7fff991786c0 (LWP 9562)]
[Thread 0x7fff991786c0 (LWP 9562) exited]
[New Thread 0x7fff991786c0 (LWP 9563)]
script engine started.
[Thread 0x7fff991786c0 (LWP 9563) exited]
[New Thread 0x7fff991786c0 (LWP 9564)]
[Thread 0x7fff991786c0 (LWP 9564) exited]

Thread 21 "SDLAudioP3" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd4a016c0 (LWP 9353)]
0x00007ffff7ab5787 in fluid_player_callback ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
(gdb) where
#0  0x00007ffff7ab5787 in fluid_player_callback ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
#1  0x00007ffff7aa10ca in fluid_synth_render_blocks ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
#2  0x00007ffff7aa7702 in fluid_synth_write_s16_channels ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
#3  0x00007ffff7aa77c1 in fluid_synth_write_s16 ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
#4  0x00007ffff7a88b6d in SDLAudioCallback ()
  from /home/yona/Games/simutrans-nigth/lib/libfluidsynth.so.3
#5  0x00007ffff7cff35a in ?? () from /usr/lib64/libSDL2-2.0.so.0
#6  0x00007ffff7d73245 in ?? () from /usr/lib64/libSDL2-2.0.so.0
#7  0x00007ffff7e28189 in ?? () from /usr/lib64/libSDL2-2.0.so.0
#8  0x00007ffff729b935 in start_thread () from /lib64/libc.so.6
#9  0x00007ffff7325d68 in __clone3 () from /lib64/libc.so.6
(gdb)

prissi

The screenshot shows no bug, please describe what the bug actually does. Also, on Linux, it could be easily a bug in the Midi lib, which is threaded too.

Yona-TYT

Quote from: prissi on January 13, 2026, 01:33:54 PMThe screenshot shows no bug, please describe what the bug actually does. Also, on Linux, it could be easily a bug in the Midi lib, which is threaded too.
It's because there's no error message; Simutrans actually closes suddenly when changing music, but since I'm using gdb, this keeps the window frozen.

prissi

Then I would guess this is a fluidsynth thing combined with simutrans given the output. But I might be wrong and its just my prejustice against fluidsynth.

Yona-TYT

If I'm not mistaken, it's been over a year since I mentioned this in the forum (I lost the topic). I hadn't been able to capture it with gdb. Unfortunately, in this Linux district there are no debugging libraries and the reverse trace doesn't have much useful information. :-[

victor_18993

Fixed in r12241.

The crash was caused by Simutrans replacing/deleting the FluidSynth MIDI player while the audio thread could still be rendering it.

The fix now stops audio rendering before replacing the player, then restarts it afterwards. This also fixes the player leak that occurred during natural track changes.
Tested successfully with ALSA, SDL2, file and PulseAudio, including repeated manual and natural track changes.
Thanks for reporting this and for the original backtrace — it was very useful for reproducing the problem.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

Yona-TYT


Quote from: victor_18993 on Today at 06:48:03 PMFixed in r12241.

The crash was caused by Simutrans replacing/deleting the FluidSynth MIDI player while the audio thread could still be rendering it.

The fix now stops audio rendering before replacing the player, then restarts it afterwards. This also fixes the player leak that occurred during natural track changes.
Tested successfully with ALSA, SDL2, file and PulseAudio, including repeated manual and natural track changes.
Thanks for reporting this and for the original backtrace — it was very useful for reproducing the problem.

Amazing! This was a really elusive bug. You might stumble across it while switching tracks, but at the next Simutrans launch, it would be gone no matter how many tracks you changed. It was a bit difficult to capture with gdb 😅


Es:
Impresionante, este era un bug muy esquivo, podias toparte con él en algun momento mientras cambiabas entre pistas, y al siguiente inicio de simutrans ya no lo volvias a encontrar por mas que cambiaras de pistas musicales, fue un poco difícil capturarlo con gdb 😅

victor_18993

EN: 

If this error was complex, the good thing is that I asked the AI to recreate the case according to the log, then I let it perform interactions until it found the pattern and showed it to me, then debugging was the easy part hahaha.

ES:

Si este error era complejo, lo bueno que le pedí a la IA que recreará el caso según el log, luego la deje realizando interacciones hasta que dio con el patron y me lo mostro, despues ya depurar fue lo facil jajaja.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

Yona-TYT

How impressive AI is! I couldn't find a part that could reliably replicate the bug; it would happen once and then not again no matter how many times I repeated the same procedure.

Es:

Qué impresionante es la IA. Yo no pude encontrar un patrón que pudiera replicar el bug de manera fiable, ocurría una vez y luego no volvía a ocurrir por más que repetía el mismo procedimiento.