karlstav/cava

Segfault on startup.

Closed this issue · 5 comments

7z3m commented

Segfaults immediately on startup, upon continued attempts it eventually starts up, although bars don't move. I'm building with alsa support, sdl2, and asan, all of which are built from source, including fftw and iniparser.

I'm messing around with config parameters, changing alsa soundcard, and getting the same result.

this is the sanitizer output:

AddressSanitizer:DEADLYSIGNAL

==450==ERROR: AddressSanitizer: stack-overflow on address 0x7ff76387f7c8 (pc 0x00000050f207 bp 0x7ff7638ff990 sp 0x7ff76387f7d0 T1)
sh: setterm: not found
#0 0x50f207 in input_alsa ../input/alsa.c:73
#1 0x4d79f7 in __asan::ScopedInErrorReport::~ScopedInErrorReport() ../../../../libsanitizer/asan/asan_report.cpp:143
#2 0x4d39ed in __asan::ReportDeadlySignal(__sanitizer::SignalContext const&) ../../../../libsanitizer/asan/asan_report.cpp:220
#3 0x4d2868 in __asan::AsanOnDeadlySignal(int, void*, void*) ../../../../libsanitizer/asan/asan_posix.cpp:40
#4 0x7ff7655884f6 (/lib/ld-musl-x86_64.so.1+0x5f4f6) (BuildId: 7d364cb6e5a34d6b3afd80e9eb751c294f55aac9)

SUMMARY: AddressSanitizer: stack-overflow ../input/alsa.c:73 in input_alsa
Thread T1 created by T0 here:
#0 0x4c80d5 in pthread_create ../../../../libsanitizer/asan/asan_interceptors.cpp:245
#1 0x40b314 in main ../cava.c:435

==450==ABORTING

This is input/alsa.c line 73:

    unsigned char buf[buffer_size];
    frames = period_size / ((audio->format / 8) * CHANNELS_COUNT);

this is cava.c line 435:

thr_id = pthread_create(&p_thread, NULL, input_alsa, (void *)&audio);

When it does launch, this is the leftover error:

sh: setterm: not found
sh: setterm: not found

=================================================================
==2197==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 152 byte(s) in 1 object(s) allocated from:
#0 0x4cec00 in calloc ../../../../libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x408862 in main ../cava.c:778

SUMMARY: AddressSanitizer: 152 byte(s) leaked in 1 allocation(s).

This is cava.c line 778:

previous_bars_raw = (float *)malloc(number_of_bars * sizeof(float));

seems like the core problem is alsa related, i don't think a missing setterm should be that big of a deal since its not really present in alsa.c or cava.c except the one time.

if its a problem with my build of alsa, i apologize for wasting your time.

Desktop (please complete the following information):

  • OS: Linux, compiled from source.
  • kernel 6.12.39

Terminal emulator

  • st
  • 0.9.2

Additional context
setterm is not present.

this was fixed recently:

cc15795

just pull the latest code and it should work

7z3m commented

ok forgot to mention that i was using the latest release tarball because autogen is returning an error (when using the git repo.) i just tried cmake and it only builds libcavacore.

this is the autogen error:

configure.ac:306: error: _AX_CHECK_GL_MANUAL_LIBS_GENERIC: argument must not be empty
../lib/m4sugar/m4sh.m4:689: _AS_IF_ELSE is expanded from...
../lib/m4sugar/m4sh.m4:696: AS_IF is expanded from...
/usr/share/aclocal/ax_check_gl.m4:187: _AX_CHECK_GL_MANUAL_LIBS_GENERIC is expanded from...
../lib/m4sugar/m4sh.m4:594: AS_CASE is expanded from...
/usr/share/aclocal/ax_check_gl.m4:253: AX_CHECK_GL is expanded from...
../lib/m4sugar/m4sh.m4:696: AS_IF is expanded from...
../lib/m4sugar/m4sh.m4:696: AS_IF is expanded from...
configure.ac:306: the top level
autom4te: error: /usr/bin/m4 failed with exit status: 1
aclocal-1.17: error: autom4te failed with exit status:

7z3m commented

i just copied the necessary files into the latest release and i dont seem to be getting any segfaults, thanks for pointing that out on such a quick notice. and thanks for your effort on this great project.

7z3m commented

unrelated to the issue, how hard would it be to make the eq an actual eq and not just a visualizer? isn't the hard pretty much done? or is it a pain making it work with alsa?

edit: i'm asking if i can pull this off myself as an amateur programmer.

@7z3m not that easy I'm afraid. You would have to route all the audio trough your application. not just listen as cava does, but also send the audio back to the output. There are probably also other things to consider when making a good eq.