Open pdussault opened 5 days ago
Thanks for this detailed report! I will try to have a pass at the issue at hand here as time allows.
Issues with OCaml running callbacks unexpectedly have been the source of a lot of discussions with the compiler team. There's some work in progress, especially with the new GC implementation in the 5.x
branch but this is all too new to be usable (we've had issues with 5.1
with memory accumulation).
The libflac
API is a callback-based API, which requires a level of coordination with the OCaml stack that does trigger OCaml callbacks while executing C operation. For instance, decoding audio might need to read data which, in turn, will trigger OCaml callbacks.
For these two reasons, it's been historically pretty difficult to implement a correct OCaml binding for libflac
. The recommended alternative is to use the %ffmpeg
encoder which should not have these issues.
The only other drawback with using %ffmpeg
is that ffmpeg, like pretty much all of the existing tools around, doesn't know how to properly cut tracks in a multi-track ogg stream. Something that's been an issue for decades now and, in most people opinion, stems from a rather bad ogg spec for track chaining.
Hope this helps!
Hi Toots,
As work around, I've changed the radio to use %ffmpeg instead of %ogg %flac, and so far, no crash reported. And I haven't seen problem to cut track in the stream so far.
For the record, here's the modified radio:
output.icecast(%ffmpeg(format="ogg", %audio(codec="flac", ar=48000, channels=2)),
host = "localhost", port = 8000, user = "user",
password = "password", mount = "radio", description = "radio", send_icy_metadata=false, format = "application/ogg",
radio)
Thanks for your help!
Description
Randomly, liquidsoap crashes when running flac stream with icecast, the core dump reports:
That happens after having upgraded liquidsoap from 2.0.7 to 2.2.5.
and the liquidsoap reports:
Steps to reproduce
Code from the radio:
radio = fallback([ request.queue(id="request"),
[...]
])
Add some jingles
radio = random(weights = [1, 10],[jingles, radio])
And finally the security
radio = fallback(track_sensitive = false, [blank.strip(max_blank=20.,radio), security])
radio = amplify(1.,override="replaygain_track_gain",radio)
Stream it out
output.icecast(%ogg(%flac(samplerate=48000,channels=2,compression=5,bits_per_sample=16)),
host = "localhost", port = 8000, user = "user",
password = "password", mount = "radio", description = "radio",
radio)
Expected behavior
The product should not crash. Former version in use with the radio script was 2.0.7 that was not crashing.
Liquidsoap version
Liquidsoap build config
Installation method
From OPAM
Additional Info
Similar to https://github.com/savonet/liquidsoap/issues/3495, which has been fixed in 2023.
gdb against the coredump:
(gdb) info threads
[Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/.opam/default/bin/liquidsoap --debug-levels ./radioflac.liq'. Program terminated with signal SIGSEGV, Segmentation fault.
0 0x00007f22c736c1c8 in ?? ()
[Current thread is 1 (Thread 0x7f22bffff6c0 (LWP 4850))] (gdb) bt
[Switching to thread 1 (Thread 0x7f22bffff6c0 (LWP 4850))]
0 0x00007f22c736c1c8 in ?? ()
(gdb) bt
[Switching to thread 2 (Thread 0x7f22c4ced6c0 (LWP 4847))]
0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 3 (Thread 0x7f22beffd6c0 (LWP 4852))]
0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 4 (Thread 0x7f22c54ee6c0 (LWP 4846))]
0 0x00007f22ea8cc3ec in select () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 5 (Thread 0x7f22e5e17a00 (LWP 4768))]
0 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 6 (Thread 0x7f22bdffb6c0 (LWP 4854))]
0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 7 (Thread 0x7f22be7fc6c0 (LWP 4853))]
0 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
(gdb) bt
[Switching to thread 8 (Thread 0x7f22bf7fe6c0 (LWP 4851))]
0 0x00007f22ea8bc76b in sched_getcpu () from /lib64/libc.so.6
(gdb) bt
``