Audio4Linux / JDSP4Linux

An audio effect processor for PipeWire and PulseAudio clients
GNU General Public License v3.0
915 stars 35 forks source link

Constant crashes #145

Closed HanabishiRecca closed 1 year ago

HanabishiRecca commented 1 year ago

Using the latest master commit (ec630e9) JamesDSP is constantly crashing. I am able to fairly consistently reproduce the issue by playing audio/video in Firefox and then opening Discord in a new tab.

Arch Linux pipewire 0.3.76

Backtrace:

Thread 12 "jamesdsp" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd4dea6c0 (LWP 30614)]
__pthread_clockjoin_ex (threadid=11991548691176, thread_return=0x0, clockid=0, abstime=0x0, block=true) at pthread_join_common.c:43

43    if (INVALID_NOT_TERMINATED_TD_P (pd))
#0  __pthread_clockjoin_ex (threadid=11991548691176, thread_return=0x0, clockid=0, abstime=0x0, block=true) at pthread_join_common.c:43
        pd = 0xae8000002e8
        self = <optimized out>
        result = <optimized out>
        pd_result = <optimized out>
#1  0x0000555556124459 in thread_exit2x4x2(TwoStageFFTConvolver2x4x2*) (conv=0x7fff6c02d990) at ../libjamesdsp/../../JDSP4Linux/libjamesdsp/subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/generalDSP/TwoStageFFTConvolver.c:157
        info = 0x7fff6c02dcd8
#2  0x000055555612c116 in TwoStageFFTConvolver2x4x2Free(TwoStageFFTConvolver2x4x2*) (conv=0x7fff6c02d990) at ../libjamesdsp/../../JDSP4Linux/libjamesdsp/subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/generalDSP/TwoStageFFTConvolver.c:528
#3  0x00005555560bf625 in CrossfeedEnable(JamesDSPLib*, char) (jdsp=0x7fffdc1ad010, enable=0 '\000') at ../libjamesdsp/../../JDSP4Linux/libjamesdsp/subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/crossfeed.c:59
        seg2Len = 0
#4  0x0000555556124a93 in JamesDSPRefreshConvolutions(JamesDSPLib*, char) (jdsp=0x7fffdc1ad010, refreshAll=1 '\001') at ../libjamesdsp/../../JDSP4Linux/libjamesdsp/subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c:256
#5  0x0000555556126654 in pfloat32(JamesDSPLib*, float*, float*, float*, float*, size_t) (jdsp=0x7fffdc1ad010, x1=0x7fffdc190040, x2=0x7fffdc187040, y1=0x7fffdc17e040, y2=0x7fffdc175040, n=512) at ../libjamesdsp/../../JDSP4Linux/libjamesdsp/subtree/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c:851
#6  0x0000555555f867de in PwJamesDspPlugin::process(float*, float*, float*, float*, unsigned long) (this=0x555556a694e0, left_in=0x7fffdc190040, right_in=0x7fffdc187040, left_out=0x7fffdc17e040, right_out=0x7fffdc175040, length=512) at ../../JDSP4Linux/src/audio/pipewire/PwJamesDspPlugin.cpp:90
#7  0x0000555555f85dec in (anonymous namespace)::on_process(void*, spa_io_position*) (userdata=0x555556a69610, position=0x7ffff0b46230) at ../../JDSP4Linux/src/audio/pipewire/PwBasePlugin.cpp:79
        d = 0x555556a69610
        n_samples = @0x7ffff0b46290: 512
        rate = @0x7ffff0b46284: 48000
        in_left = 0x7fffdc190040
        in_right = 0x7fffdc187040
        out_left = 0x7fffdc17e040
        out_right = 0x7fffdc175040
#8  0x00007ffff7be1bb8 in call_process (impl=0x555556a8e6f0) at ../pipewire/src/pipewire/filter.c:1015
        _f = <optimized out>
        impl = 0x555556a8e6f0
        p = <optimized out>
        b = <optimized out>
        drained = <optimized out>
        res = 0
#9  impl_node_process (object=0x555556a8e6f0) at ../pipewire/src/pipewire/filter.c:1078
        impl = 0x555556a8e6f0
        p = <optimized out>
        b = <optimized out>
        drained = <optimized out>
        res = 0
#10 0x00007ffff7bf7a69 in process_node (data=0x55555707ea40) at ../pipewire/src/pipewire/impl-node.c:1230
        _f = <optimized out>
        _res = <optimized out>
        _n = <optimized out>
        this = 0x55555707ea40
        a = 0x7ffff24ea000
        status = <optimized out>
        p = <optimized out>
        data_system = 0x555556a60970
        nsec = <optimized out>
        cmd = 1
        this = 0x55555707ea40
        __func__ = "node_on_fd_events"
#11 node_on_fd_events (source=<optimized out>) at ../pipewire/src/pipewire/impl-node.c:1303
        cmd = 1
        this = 0x55555707ea40
        __func__ = "node_on_fd_events"
#12 0x00007fffdc4b25b6 in loop_iterate (object=0x555556a60a08, timeout=<optimized out>) at ../pipewire/spa/plugins/support/loop.c:483
        s = <optimized out>
        impl = 0x555556a60a08
        ep = {{events = 1, data = 0x55555707f068}, {events = 0, data = 0x0} <repeats 31 times>}
        e = <optimized out>
        i = 0
        nfds = 1
#13 0x00007ffff7bdaaf2 in do_loop (user_data=0x555556a608a0) at ../pipewire/src/pipewire/data-loop.c:65
        __clframe = {__cancel_routine = <optimized out>, __cancel_arg = <optimized out>, __do_it = <optimized out>, __cancel_type = <optimized out>}
        this = 0x555556a608a0
        res = <optimized out>
        cb = <optimized out>
        m = <optimized out>
        data = <optimized out>
        iterate = <optimized out>
        __func__ = "do_loop"
#14 0x00007ffff609d44b in start_thread (arg=<optimized out>) at pthread_create.c:444
        ret = <optimized out>
        pd = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737321226608, -488499318024781585, -248, 0, 140737488326976, 140736756359168, 488405025297318127, 488478274104115439}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#15 0x00007ffff6120e40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

P.S. It says something about convolver and crossfeed, but they are actually disabled. The only enabled effect is Equalizer.

timschneeb commented 1 year ago

I'm not completely familiar with the internals of libjamesdsp, but it looks like this is related to the new benchmarking feature which improves performance of any effects that make use of convolver modules. The RefreshConvolutions function is called when the benchmark has finished (about 1 minute after launch) or every time the buffer size changes.

Could you try to disable the 'Benchmark on boot' option in the settings (and restart the app) and see if that changes anything?

HanabishiRecca commented 1 year ago

Could you try to disable the 'Benchmark on boot' option in the settings (and restart the app) and see if that changes anything?

It is disabled already.

timschneeb commented 1 year ago

I can't seem to reproduce this even when forcing buffer size changes.

Either way, I pushed a patch to my libjamesdsp fork that should resolve this issue, although I can't tell for sure if it's effective. Please try to rebuild from master and see if the issue is resolved.

HanabishiRecca commented 1 year ago

Yes, seems to be fixed.

Now I guess this event

[KNL] Log::kernel: EffectDSPMain: ignoring call to JamesDSPRefreshConvolutions(...) because benchmarks are disabled

occurs instead of crashes.

timschneeb commented 1 year ago

I was finally able to reproduce this bug and fix it properly. The patch is available on the main branch, so the convolver benchmarking/optimizations can now be safely re-enabled if desired.