MayamaTakeshi / sip-lab

A node module that helps to write SIP functional tests
3 stars 2 forks source link

Occasional crash when running 'node samples/g729.js' #99

Closed MayamaTakeshi closed 1 month ago

MayamaTakeshi commented 1 month ago

Running this inside gdb we eventually get:


on_media_update call_id=1 active remote_sdp: v=0
o=- 3925593201 3925593201 IN IP4 0.0.0.0
s=pjmedia
t=0 0
m=audio 10000 RTP/AVP 18 120
c=IN IP4 127.0.0.1
b=TIAS:11800
a=rtcp:10001 IN IP4 127.0.0.1
a=sendrecv
a=rtpmap:18 G729/8000
a=rtpmap:120 telephone-event/8000
a=fmtp:120 0-16

call_id=1 restart_media_stream: stream characteristics no change
audio_endpoint_remove_port

Thread 11 "clock" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffcd9fc640 (LWP 25472)]
0x00007ffff4cb2634 in get_frame (port=0x5c950e8, frame=0x7fffcd9fbc60) at ../src/pjmedia/stream.c:643
643                 if (stream->codec->op->recover &&
(gdb) bt
#0  0x00007ffff4cb2634 in get_frame (port=0x5c950e8, frame=0x7fffcd9fbc60) at ../src/pjmedia/stream.c:643
#1  0x00007ffff4ca0dfc in read_port (type=<synthetic pointer>, count=160, frame=<optimized out>, cport=0x5c997e8, conf=0x5c64900) at ../src/pjmedia/conference.c:1588
#2  get_frame (this_port=<optimized out>, frame=0x7fffcd9fbcd0) at ../src/pjmedia/conference.c:2042
#3  0x00007ffff4ca5fb3 in clock_callback (ts=0x5c997a8, user_data=0x5c967a8) at ../src/pjmedia/master_port.c:193
#4  0x00007ffff4cc154b in clock_thread (arg=0x5c99788) at ../src/pjmedia/clock_thread.c:391
#5  0x00007ffff4d15498 in thread_main (param=0x5c6dd68) at ../src/pj/os_core_unix.c:701
#6  0x00007ffff7894ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#7  0x00007ffff7926850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) 

This probably is not related to G729. As we can see, it happens after "audio_endpoint_remove_port". So probably we are not properly syncing access to stream or some related object and we are nullifying some field and when the thread writing data to the stream tries to read it, it segfaults.

Commit: 39c4bd5514d5ea5e8757e19fa6c330df9e758d93

MayamaTakeshi commented 1 month ago

I copied samples/g729.js to samples/pcma.js and adjusted it to use PCMA instead of G729 but could not reproduce this issue exact issue. But I got (once):


call_id=0 restart_media_stream: stream characteristics no change
audio_endpoint_remove_port

Thread 12 "clock" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffcd1fb640 (LWP 18658)]
get_frame (port=0x5c814f8, frame=0x7fffcd1fac60) at ../src/pjmedia/stream.c:770
770             status = pjmedia_codec_decode( stream->codec, &frame_in,
(gdb) bt
#0  get_frame (port=0x5c814f8, frame=0x7fffcd1fac60) at ../src/pjmedia/stream.c:770
#1  0x00007ffff4ca0dfc in read_port (type=<synthetic pointer>, count=160, frame=<optimized out>, cport=0x5c65d50, conf=0x5c846c0) at ../src/pjmedia/conference.c:1588
#2  get_frame (this_port=<optimized out>, frame=0x7fffcd1facd0) at ../src/pjmedia/conference.c:2042
#3  0x00007ffff4ca5fb3 in clock_callback (ts=0x5c65d10, user_data=0x5c85948) at ../src/pjmedia/master_port.c:193
#4  0x00007ffff4cc154b in clock_thread (arg=0x5c65cf0) at ../src/pjmedia/clock_thread.c:391
#5  0x00007ffff4d15498 in thread_main (param=0x5c66958) at ../src/pj/os_core_unix.c:701
#6  0x00007ffff7894ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#7  0x00007ffff7926850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) 

which should have the same underlyaing cause.

MayamaTakeshi commented 1 month ago

The problem was that I was removing the ports before calling pjmedia_master_port_stop.