Skip to content

[1.x] Segmentation fault in AudioBridge #3587

@woutd

Description

@woutd

Today, Janus crashed with a segmentation fault.
After checking logs and core file, I noticed it was a call to opus_encoder_ctl by the AudioBridge plugin which caused it.

In src/plugins/janus_audiobridge.c there are 44 calls to that function, but I am focusing on the ones which use participant->encoder.

The following one in janus_audiobridge_handler seems suspicious to me:

if(exploss) {
        participant->expected_loss = expected_loss;
        opus_encoder_ctl(participant->encoder, OPUS_SET_PACKET_LOSS_PERC(participant->expected_loss));
}

There is no check on participant->encoder while on the lines just above there is:

if(participant->encoder)
        opus_encoder_ctl(participant->encoder, OPUS_SET_BITRATE(participant->opus_bitrate ? participant->opus_bitrate : OPUS_AUTO));
if(quality) {
        participant->opus_complexity = complexity;
        if(participant->encoder)
                opus_encoder_ctl(participant->encoder, OPUS_SET_COMPLEXITY(participant->opus_complexity));
}

What version of Janus is this happening on?
1.3.2

Have you tested a more recent version of Janus too?
No, 1.3.2 is latest

Was this working before?
Unknown

Is there a gdb or libasan trace of the issue?
No debug symbols, but there is a core file with following backtrace:

#0  0x00007f436068b4a6 in opus_encoder_ctl () at /usr/lib/x86_64-linux-gnu/libopus.so.0
#1  0x00007f43606ec830 in janus_audiobridge_handler () at /data/global/lib/janus-1.3.2_bullseye_amd64/lib/janus/plugins/libjanus_audiobridge.so
#2  0x00007f43655a905d in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f4364fd6ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#4  0x00007f4364ef6adf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Additional context
Same second as crash the following log entries:

[Tue Oct  7 09:10:03 2025] [1008219414513122] There's a message for JANUS AudioBridge plugin
[Tue Oct  7 09:10:03 2025] [1008219414513122] Remote SDP:
...
[Tue Oct  7 09:10:03 2025] Detaching handle from JANUS AudioBridge plugin; 0x7f434c026000 0x7f434c02b380 0x7f434c026000 0x7f434c03b750
[Tue Oct  7 09:10:03 2025] [1008219414513122] Handle detached, scheduling destruction
[Tue Oct  7 09:10:03 2025] [7875649576810478] Hanging up PeerConnection because of a Detach
[Tue Oct  7 09:10:03 2025] Detaching handle from JANUS Streaming plugin; 0x7f434c02e450 0x7f434c05c900 0x7f434c02e450 0x7f434c05e2f0
[Tue Oct  7 09:10:03 2025] Preparing JSON event as a reply
[Tue Oct  7 09:10:03 2025] [7875649576810478] Handle detached, scheduling destruction

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions