Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signal handler called from camlFlac_ogg.create_inner #4133

Open
pdussault opened this issue Sep 14, 2024 · 2 comments
Open

signal handler called from camlFlac_ogg.create_inner #4133

pdussault opened this issue Sep 14, 2024 · 2 comments
Labels

Comments

@pdussault
Copy link

pdussault commented Sep 14, 2024

Description

Randomly, liquidsoap crashes when running flac stream with icecast, the core dump reports:

  #0  0x00007f22c736c1c8 in ??? ()
  #1  0x0000557a2f8ef884 in <signal handler called> ()
  #2  0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, arg=<optimized out>) at runtime/callback.c:201
  #3  0x0000557a2f87ef99 in enc_write_callback
      (encoder=<optimized out>, buffer=0x7f228d8e5208 "OggS", bytes=28, samples=<optimized out>, current_frame=<optimized out>, client_data=<optimized out>) at flac_stubs.c:671
  #4  0x00007f22ed45bb53 in ??? () at /usr/lib64/libFLAC.so.12
  #5  0x00007f22ed44eef3 in ??? () at /usr/lib64/libFLAC.so.12
  #6  0x00007f22ed4504b6 in ??? () at /usr/lib64/libFLAC.so.12
  #7  0x00007f22ed4507e3 in FLAC__stream_encoder_init_ogg_stream () at /usr/lib64/libFLAC.so.12
  #8  0x0000557a2f87c813 in ocaml_flac_encoder_ogg_create (comments=<optimized out>, params=<optimized out>, _enc_cb=<optimized out>, _serialno=<optimized out>) at flac_ogg_stubs.c:76
  #9  0x0000557a2f8ef7af in <signal handler called> ()
  #10 0x0000557a2f37df11 in camlFlac_ogg.create_inner_1079 () at src/flac_ogg.ml:97
  #11 0x0000557a2f3734a2 in camlOgg_flac_encoder.get_enc_445 () at src/core/ogg_formats/ogg_flac_encoder.ml:53
  #12 0x0000557a2f3735d7 in camlOgg_flac_encoder.header_encoder_611 () at src/core/ogg_formats/ogg_flac_encoder.ml:63
  #13 0x0000557a2f37491a in camlOgg_muxer.register_track_1208 () at src/core/ogg_formats/ogg_muxer.ml:186
  #14 0x0000557a2f376b8a in camlOgg_encoder.f_1643 () at src/core/encoder/encoders/ogg_encoder.ml:138

That happens after having upgraded liquidsoap from 2.0.7 to 2.2.5.

and the liquidsoap reports:

  ...
  2024/09/13 16:39:10 [request.683:4] Pushed ["/flac/03._Easy_Listen__Blues.flac";...].
  2024/09/13 16:39:10 [ogg.muxer:4] test: Setting end of track d05b9c2.
  2024/09/13 16:39:10 [ogg.muxer:4] `test:` Every ogg logical tracks have ended: setting end of stream.
  2024/09/13 16:39:10 [ogg.muxer:4] test: Starting new sequentialized ogg stream.
  Violación de segmento (`core' generado)

Steps to reproduce

Code from the radio:

radio = fallback([ request.queue(id="request"),

  switch([        

[...]

])

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 2.2.5+dev
Copyright (c) 2003-2024 Savonet team
Liquidsoap is open-source software, released under GNU General Public License.
See <http://liquidsoap.info> for more information.

Liquidsoap build config

* Liquidsoap version  : 2.2.5+dev

 * Compilation options
   - Release build       : false
   - Git SHA             : (none)
   - OCaml version       : 5.2.0
   - OS type             : Unix
   - Libs versions       : angstrom=0.16.0 bigstringaf=0.10.0 bytes=[distributed with OCaml 4.02 or above] camlp-streams camomile.lib=2.0 cry=1.0.3 curl=0.9.2 dtools=0.4.5 dune-build-info=3.16.0 dune-private-libs.dune-section=3.16.0 dune-site=3.16.0 dune-site.private=3.16.0 duppy=0.9.4 ffmpeg-av=1.1.11 ffmpeg-avcodec=1.1.11 ffmpeg-avdevice=1.1.11 ffmpeg-avfilter=1.1.11 ffmpeg-avutil=1.1.11 ffmpeg-swresample=1.1.11 ffmpeg-swscale=1.1.11 fileutils=0.6.4 flac=0.5.0 flac.decoder=0.5.0 flac.ogg=0.5.0 gen=1.1 lame=0.3.7 liquidsoap-lang=2.2.5 liquidsoap-lang.console=2.2.5 liquidsoap_builtins liquidsoap_core liquidsoap_ffmpeg liquidsoap_flac liquidsoap_lame liquidsoap_mad liquidsoap_ogg liquidsoap_ogg_flac liquidsoap_optionals liquidsoap_oss liquidsoap_runtime liquidsoap_samplerate liquidsoap_taglib liquidsoap_vorbis mad=0.5.3 magic-mime=1.3.1 menhirLib=20240715 metadata=0.3.0 mm=0.8.5 mm.audio=0.8.5 mm.base=0.8.5 mm.image=0.8.5 mm.midi=0.8.5 mm.video=0.8.5 ogg=0.7.4 ogg.decoder=0.7.4 pcre=7.5.0 ppx_string.runtime=v0.17.0 re=1.12.0 samplerate=0.1.6 sedlex=3.2 seq=[distributed with OCaml 4.07 or above] stdlib-shims=0.3.0 str=5.2.0 stringext=1.6.0 taglib=0.3.10 threads=5.2.0 unix=5.2.0 uri=4.4.0 vorbis=0.8.0 vorbis.decoder=0.8.0
   - architecture        : amd64
   - host                : x86_64-pc-linux-gnu
   - target              : x86_64-pc-linux-gnu
   - system              : linux
   - ocamlopt_cflags     : -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -pthread
   - native_c_compiler   : gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -pthread -D_FILE_OFFSET_BITS=64
   - native_c_libraries  : -lm -lpthread

 * Configured paths
   - mode              : default
   - standard library  : (set by dune-site)
   - scripted binaries : (set by dune-site)
   - rundir            : (set by dune-site)
   - logdir            : (set by dune-site)
   - camomile files    : (set by dune-site)

 * Supported input formats
   - MP3               : yes
   - AAC               : no (requires faad)
   - Ffmpeg            : yes
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : no (requires opus)
   - Speex             : no (requires speex)
   - Theora            : no (requires theora)
   - Vorbis            : yes

 * Supported output formats
   - FDK-AAC           : no (requires fdkaac)
   - Ffmpeg            : yes
   - MP3               : yes
   - MP3 (fixed-point) : no (requires shine)
   - Flac (native)     : yes
   - Flac (ogg)        : yes
   - Opus              : no (requires opus)
   - Speex             : no (requires speex)
   - Theora            : no (requires theora)
   - Vorbis            : yes

 * Tags
   - Taglib (ID3 tags) : yes
   - Vorbis            : yes

 * Input / output
   - ALSA              : no (requires alsa)
   - AO                : no (requires ao)
   - FFmpeg            : yes
   - GStreamer         : no (requires gstreamer)
   - JACK              : no (requires bjack)
   - OSS               : yes
   - Portaudio         : no (requires portaudio)
   - Pulseaudio        : no (requires pulseaudio)
   - SRT               : no (requires srt)

 * Audio manipulation
   - FFmpeg            : yes
   - LADSPA            : no (requires ladspa)
   - Lilv              : no (requires lilv)
   - Samplerate        : yes
   - SoundTouch        : no (requires soundtouch)
   - StereoTool        : no (requires ctypes-foreign)

 * Video manipulation
   - camlimages        : no (requires camlimages)
   - FFmpeg            : yes
   - frei0r            : no (requires frei0r)
   - ImageLib          : no (requires imagelib)
   - SDL               : no (requires tsdl-image & tsdl-ttf)

 * MIDI manipulation
   - DSSI              : no (requires dssi)

 * Visualization
   - GD                : no (requires gd)
   - Graphics          : no (requires graphics)
   - SDL               : no (requires tsdl-image & tsdl-ttf)

 * Additional libraries
   - FFmpeg filters    : yes
   - FFmpeg devices    : yes
   - inotify           : no (requires inotify)
   - irc               : no (requires irc-client-unix)
   - jemalloc          : no (requires jemalloc)
   - lastfm            : no (requires lastfm)
   - lo                : no (requires lo)
   - memtrace          : no (requires memtrace)
   - mem_usage         : no (requires mem_usage)
   - osc               : no (requires osc-unix)
   - ssl               : no (requires ssl)
   - tls               : no (requires tls-liquidsoap)
   - posix-time2       : no (requires posix)
   - windows service   : no (requires winsvc)
   - YAML support      : no (requires yaml)
   - XML playlists     : no (requires xmlplaylist)

 * Monitoring
   - Prometheus        : no (requires prometheus)

Installation method

From OPAM

Additional Info

Similar to #3495, which has been fixed in 2023.

gdb against the coredump:

(gdb) info threads

  Id   Target Id                        Frame 
  1    Thread 0x7f22bffff6c0 (LWP 4850) 0x00007f22c736c1c8 in ?? ()
  2    Thread 0x7f22c4ced6c0 (LWP 4847) 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
  3    Thread 0x7f22beffd6c0 (LWP 4852) 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
  4    Thread 0x7f22c54ee6c0 (LWP 4846) 0x00007f22ea8cc3ec in select () from /lib64/libc.so.6
* 5    Thread 0x7f22e5e17a00 (LWP 4768) 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
  6    Thread 0x7f22bdffb6c0 (LWP 4854) 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
  7    Thread 0x7f22be7fc6c0 (LWP 4853) 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
  8    Thread 0x7f22bf7fe6c0 (LWP 4851) 0x00007f22ea8bc76b in sched_getcpu () from /lib64/libc.so.6

[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

#0  0x00007f22c736c1c8 in ??? ()
#1  0x0000557a2f8ef884 in <signal handler called> ()
#2  0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, arg=<optimized out>) at runtime/callback.c:201
#3  0x0000557a2f87ef99 in enc_write_callback
    (encoder=<optimized out>, buffer=0x7f228d8e5208 "OggS", bytes=28, samples=<optimized out>, current_frame=<optimized out>, client_data=<optimized out>) at flac_stubs.c:671
#4  0x00007f22ed45bb53 in ??? () at /usr/lib64/libFLAC.so.12
#5  0x00007f22ed44eef3 in ??? () at /usr/lib64/libFLAC.so.12
#6  0x00007f22ed4504b6 in ??? () at /usr/lib64/libFLAC.so.12
#7  0x00007f22ed4507e3 in FLAC__stream_encoder_init_ogg_stream () at /usr/lib64/libFLAC.so.12
#8  0x0000557a2f87c813 in ocaml_flac_encoder_ogg_create (comments=<optimized out>, params=<optimized out>, _enc_cb=<optimized out>, _serialno=<optimized out>) at flac_ogg_stubs.c:76
#9  0x0000557a2f8ef7af in <signal handler called> ()
#10 0x0000557a2f37df11 in camlFlac_ogg.create_inner_1079 () at src/flac_ogg.ml:97
#11 0x0000557a2f3734a2 in camlOgg_flac_encoder.get_enc_445 () at src/core/ogg_formats/ogg_flac_encoder.ml:53
#12 0x0000557a2f3735d7 in camlOgg_flac_encoder.header_encoder_611 () at src/core/ogg_formats/ogg_flac_encoder.ml:63
#13 0x0000557a2f37491a in camlOgg_muxer.register_track_1208 () at src/core/ogg_formats/ogg_muxer.ml:186
#14 0x0000557a2f376b8a in camlOgg_encoder.f_1643 () at src/core/encoder/encoders/ogg_encoder.ml:138
#15 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#16 0x0000557a2f3f7bd8 in camlEncoder.fun_2083 () at src/core/tools/tutils.ml:116
#17 0x0000557a2f43a1fa in camlOutput.fun_2604 () at src/core/outputs/output.ml:267
#18 0x0000557a2f437a73 in camlOutput.fun_2436 () at src/core/outputs/output.ml:192
#19 0x0000557a2f4067c7 in camlClock.fun_2451 () at src/core/clock.ml:318
#20 0x0000557a2f7fac7c in camlStdlib__List.fold_left_380 () at list.ml:123
#21 0x0000557a2f40333a in camlClock.fun_2397 () at src/core/clock.ml:315
#22 0x0000557a2f4064ae in camlClock.loop_1229 () at src/core/clock.ml:277
#23 0x0000557a2f403985 in camlClock.fun_2355 () at src/core/clock.ml:280
#24 0x0000557a2f3e33f5 in camlTutils.process_1235 () at src/core/tools/tutils.ml:186
#25 0x0000557a2f7b1117 in camlThread.fun_768 () at thread.ml:48
#26 0x0000557a2f8ef884 in <signal handler called> ()
#27 0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, closure@entry=139787592974768, arg=<optimized out>, arg@entry=1) at runtime/callback.c:201
#28 0x0000557a2f8ad332 in caml_thread_start (v=<optimized out>) at st_stubs.c:634
#29 0x00007f22ea84f7f8 in ??? () at /lib64/libc.so.6
#30 0x00007f22ea8ceccc in ??? () at /lib64/libc.so.6
#31 0x0000000000000000 in ??? ()

[Switching to thread 1 (Thread 0x7f22bffff6c0 (LWP 4850))]
#0 0x00007f22c736c1c8 in ?? ()
(gdb) bt

#0  0x00007f22c736c1c8 in ??? ()
#1  0x0000557a2f8ef884 in <signal handler called> ()
#2  0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, arg=<optimized out>) at runtime/callback.c:201
#3  0x0000557a2f87ef99 in enc_write_callback
    (encoder=<optimized out>, buffer=0x7f228d8e5208 "OggS", bytes=28, samples=<optimized out>, current_frame=<optimized out>, client_data=<optimized out>) at flac_stubs.c:671
#4  0x00007f22ed45bb53 in ??? () at /usr/lib64/libFLAC.so.12
#5  0x00007f22ed44eef3 in ??? () at /usr/lib64/libFLAC.so.12
#6  0x00007f22ed4504b6 in ??? () at /usr/lib64/libFLAC.so.12
#7  0x00007f22ed4507e3 in FLAC__stream_encoder_init_ogg_stream () at /usr/lib64/libFLAC.so.12
#8  0x0000557a2f87c813 in ocaml_flac_encoder_ogg_create (comments=<optimized out>, params=<optimized out>, _enc_cb=<optimized out>, _serialno=<optimized out>) at flac_ogg_stubs.c:76
#9  0x0000557a2f8ef7af in <signal handler called> ()
#10 0x0000557a2f37df11 in camlFlac_ogg.create_inner_1079 () at src/flac_ogg.ml:97
#11 0x0000557a2f3734a2 in camlOgg_flac_encoder.get_enc_445 () at src/core/ogg_formats/ogg_flac_encoder.ml:53
#12 0x0000557a2f3735d7 in camlOgg_flac_encoder.header_encoder_611 () at src/core/ogg_formats/ogg_flac_encoder.ml:63
#13 0x0000557a2f37491a in camlOgg_muxer.register_track_1208 () at src/core/ogg_formats/ogg_muxer.ml:186
#14 0x0000557a2f376b8a in camlOgg_encoder.f_1643 () at src/core/encoder/encoders/ogg_encoder.ml:138
#15 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#16 0x0000557a2f3f7bd8 in camlEncoder.fun_2083 () at src/core/tools/tutils.ml:116
#17 0x0000557a2f43a1fa in camlOutput.fun_2604 () at src/core/outputs/output.ml:267
#18 0x0000557a2f437a73 in camlOutput.fun_2436 () at src/core/outputs/output.ml:192
#19 0x0000557a2f4067c7 in camlClock.fun_2451 () at src/core/clock.ml:318
#20 0x0000557a2f7fac7c in camlStdlib__List.fold_left_380 () at list.ml:123
#21 0x0000557a2f40333a in camlClock.fun_2397 () at src/core/clock.ml:315
#22 0x0000557a2f4064ae in camlClock.loop_1229 () at src/core/clock.ml:277
#23 0x0000557a2f403985 in camlClock.fun_2355 () at src/core/clock.ml:280
#24 0x0000557a2f3e33f5 in camlTutils.process_1235 () at src/core/tools/tutils.ml:186
#25 0x0000557a2f7b1117 in camlThread.fun_768 () at thread.ml:48
#26 0x0000557a2f8ef884 in <signal handler called> ()
#27 0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, closure@entry=139787592974768, arg=<optimized out>, arg@entry=1) at runtime/callback.c:201
#28 0x0000557a2f8ad332 in caml_thread_start (v=<optimized out>) at st_stubs.c:634
#29 0x00007f22ea84f7f8 in ??? () at /lib64/libc.so.6
#30 0x00007f22ea8ceccc in ??? () at /lib64/libc.so.6
#31 0x0000000000000000 in ??? ()

[Switching to thread 2 (Thread 0x7f22c4ced6c0 (LWP 4847))]
#0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea84c085 in ??? () at /lib64/libc.so.6
#1  0x0000557a318210f8 in ??? ()
#2  0x0000000000000000 in ??? ()

[Switching to thread 3 (Thread 0x7f22beffd6c0 (LWP 4852))]
#0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea84c085 in ??? () at /lib64/libc.so.6
#1  0x00007f22ac002c9c in ??? ()
#2  0x0000000000000000 in ??? ()

[Switching to thread 4 (Thread 0x7f22c54ee6c0 (LWP 4846))]
#0 0x00007f22ea8cc3ec in select () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea8cc3ec in select () at /lib64/libc.so.6
#1  0x0000557a2f8ac82c in st_msleep (msec=50) at /.opam/default/.opam-switch/build/ocaml-base-compiler.5.2.0/otherlibs/systhreads/st_posix.h:25
#2  caml_thread_tick (arg=<optimized out>) at /.opam/default/.opam-switch/build/ocaml-base-compiler.5.2.0/otherlibs/systhreads/st_pthreads.h:305
#3  0x00007f22ea84f7f8 in ??? () at /lib64/libc.so.6
#4  0x00007f22ea8ceccc in ??? () at /lib64/libc.so.6
#5  0x0000000000000000 in ??? ()

[Switching to thread 5 (Thread 0x7f22e5e17a00 (LWP 4768))]
#0 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea8c0eff in ??? () at /lib64/libc.so.6
#1  0x0000557a317d6030 in ??? ()
#2  0x0000557a318862c0 in ??? ()
#3  0x0000000000000001 in ??? ()
#4  0xffffffff2f8e8617 in ??? ()
#5  0x0000000000000001 in ??? ()
#6  0x0000557a2f8abbd5 in poll (__timeout=-1, __nfds=1, __fds=0x557a318862c0) at /usr/include/bits/poll2.h:44
#7  caml_poll (_read=<optimized out>, _write=<optimized out>, _err=<optimized out>, _timeout=<optimized out>) at duppy_stubs.c:95
#8  0x0000557a2f8ef7af in <signal handler called> ()
#9  0x0000557a2f780562 in camlDuppy.poll_597 () at src/duppy.ml:39
#10 0x0000557a2f3e3045 in camlTutils.wait_for_done_1172 () at src/core/tools/tutils.ml:168
#11 0x0000557a2f3e2f40 in camlTutils.wait_done_1170 () at src/core/tools/tutils.ml:171
#12 0x0000557a2f3e4a87 in camlTutils.main_1581 () at src/core/tools/tutils.ml:362
#13 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#14 0x0000557a2f3cc5a6 in camlLifecycle.action_457 () at src/core/tools/lifecycle.ml:64
#15 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#16 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#17 0x0000557a2f7fab80 in camlStdlib__List.iter_366 () at list.ml:112
#18 0x0000557a2f33c8e6 in camlDune__exe__Liquidsoap.entry () at src/runtime/runner.default.ml:25
#19 0x0000557a2f334787 in caml_program ()
#20 0x0000557a2f8ef884 in <signal handler called> ()
#21 0x0000557a2f8ef22d in caml_startup_common (pooling=<optimized out>, argv=0x7ffd24434238) at runtime/startup_nat.c:132
#22 caml_startup_common (argv=0x7ffd24434238, pooling=<optimized out>) at runtime/startup_nat.c:88
#23 0x0000557a2f8ef29f in caml_startup_exn (argv=<optimized out>) at runtime/startup_nat.c:139
#24 caml_startup (argv=<optimized out>) at runtime/startup_nat.c:144
#25 caml_main (argv=<optimized out>) at runtime/startup_nat.c:151
#26 0x0000557a2f331c02 in main (argc=<optimized out>, argv=<optimized out>) at runtime/main.c:37

[Switching to thread 6 (Thread 0x7f22bdffb6c0 (LWP 4854))]
#0 0x00007f22ea84c085 in ?? () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea84c085 in ??? () at /lib64/libc.so.6
#1  0x00007f22a8002c9c in ??? ()
#2  0x0000000000000000 in ??? ()

[Switching to thread 7 (Thread 0x7f22be7fc6c0 (LWP 4853))]
#0 0x00007f22ea8c0eff in ?? () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea8c0eff in ??? () at /lib64/libc.so.6
#1  0x0000557a317d6030 in ??? ()
#2  0x00007f22b4007ec0 in ??? ()
#3  0x0000000000000031 in ??? ()
#4  0x0000027e2f8e8617 in ??? ()
#5  0x0000000000000031 in ??? ()
#6  0x0000557a2f8abbd5 in poll (__timeout=638, __nfds=49, __fds=0x7f22b4007ec0) at /usr/include/bits/poll2.h:44
#7  caml_poll (_read=<optimized out>, _write=<optimized out>, _err=<optimized out>, _timeout=<optimized out>) at duppy_stubs.c:95
#8  0x0000557a2f8ef7af in <signal handler called> ()
#9  0x0000557a2f780562 in camlDuppy.poll_597 () at src/duppy.ml:39
#10 0x0000557a2f7817ea in camlDuppy.f_1089 () at src/duppy.ml:213
#11 0x0000557a2f7813ae in camlDuppy.process_1079 () at src/duppy.ml:234
#12 0x0000557a2f782209 in camlDuppy.run_1169 () at src/duppy.ml:339
#13 0x0000557a2f7823ea in camlDuppy.f_1179 () at src/duppy.ml:360
#14 0x0000557a2f781fc0 in camlDuppy.queue_inner_2972 () at src/duppy.ml:370
#15 0x0000557a2f3e33f5 in camlTutils.process_1235 () at src/core/tools/tutils.ml:186
#16 0x0000557a2f7b1117 in camlThread.fun_768 () at thread.ml:48
#17 0x0000557a2f8ef884 in <signal handler called> ()
#18 0x0000557a2f8caa30 in caml_callback_exn (closure=<optimized out>, closure@entry=139787575445632, arg=<optimized out>, arg@entry=1) at runtime/callback.c:201
#19 0x0000557a2f8ad332 in caml_thread_start (v=<optimized out>) at st_stubs.c:634
#20 0x00007f22ea84f7f8 in ??? () at /lib64/libc.so.6
#21 0x00007f22ea8ceccc in ??? () at /lib64/libc.so.6
#22 0x0000000000000000 in ??? ()

[Switching to thread 8 (Thread 0x7f22bf7fe6c0 (LWP 4851))]
#0 0x00007f22ea8bc76b in sched_getcpu () from /lib64/libc.so.6
(gdb) bt

#0  0x00007f22ea8bc76b in sched_getcpu () at /lib64/libc.so.6
#1  0x0000557a2fb5adf0 in camlRequest.111 ()
#2  0x00007f22cb9c5d98 in ??? ()
#3  0x0000000000000000 in ??? ()

``

@pdussault pdussault added the bug label Sep 14, 2024
@toots
Copy link
Member

toots commented Sep 14, 2024

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!

@pdussault
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants