Hello,
I wanted to report a segmentation fault during a TURN allocate request.
The bugs happens 4 times in a row. (out of 4 try, so every time).
It happens when the connection is closing or when I start a second one.
I'm creating the webrtc peer with libdatachannel and libjuice on one side:
IceServer turn("160.98.47.137", 8000, "user", "password", IceServer::RelayType::TurnUdp);
config.iceServers.emplace_back("stun:stun.1.google.com:19302");
config.iceServers.emplace_back(turn);
And on the web browser side:
if (document.getElementById('use-stun').checked) {
config.iceServers = [
{
urls: ['stun:stun.l.google.com:19302']
},
{
urls: ['turn:160.98.47.137:8000'],
username: 'user',
credential: 'password'
}
];
}
let pc = new RTCPeerConnection(config);
Here is the log:
Starting program: /opt/violet --file=example.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
2021-07-28 17:41:03 DEBUG udp.c:139: UDP socket bound to any:8000
2021-07-28 17:41:03 INFO server.c:235: Created server on port 8000
[New Thread 0x7ffff7d39700 (LWP 5675)]
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG server.c:607: Answering STUN unauthorized error response
2021-07-28 17:41:11 DEBUG server.c:717: Answering STUN error response with code 401
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG server.c:752: Processing TURN Allocate request
2021-07-28 17:41:11 DEBUG udp.c:157: UDP socket bound to any:65275
2021-07-28 17:41:11 INFO server.c:869: Allocated TURN relayed address 160.98.47.137:65275 for client 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 INFO server.c:737: Got STUN binding from client 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:690: Answering STUN Binding request
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:607: Answering STUN unauthorized error response
2021-07-28 17:41:11 DEBUG server.c:717: Answering STUN error response with code 401
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:752: Processing TURN Allocate request
2021-07-28 17:41:11 DEBUG udp.c:157: UDP socket bound to any:65276
2021-07-28 17:41:11 INFO server.c:869: Allocated TURN relayed address 160.98.47.137:65276 for client 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:12 DEBUG server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:12 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG server.c:941: Processing STUN ChannelBind request
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG server.c:481: Received ChannelData datagram from 194.230.158.225:59603
2021-07-28 17:41:15 DEBUG server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:15 DEBUG server.c:752: Processing TURN Allocate request
Thread 2 "violet" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7d39700 (LWP 4822)]
0x000055555556537d in addr_get_len (sa=0x0) at /opt/violet_src/deps/libjuice/src/addr.c:26
26 switch (sa->sa_family) {
(gdb) list
21
22 #include <stdio.h>
23 #include <string.h>
24
25 socklen_t addr_get_len(const struct sockaddr *sa) {
26 switch (sa->sa_family) {
27 case AF_INET:
28 return sizeof(struct sockaddr_in);
29 case AF_INET6:
30 return sizeof(struct sockaddr_in6);
(gdb) bt
#0 0x000055555556537d in addr_get_len (sa=0x0) at /opt/violet_src/deps/libjuice/src/addr.c:26
#1 0x0000555555565b6a in addr_to_string (sa=0x0, buffer=0x7ffff7d36d00 " }\323\367\377\177", size=64) at /opt/violet_src/deps/libjuice/src/addr.c:203
#2 0x000055555556600e in addr_record_to_string (record=0x0, buffer=0x7ffff7d36d00 " }\323\367\377\177", size=64) at /opt/violet_src/deps/libjuice/src/addr.c:304
#3 0x000055555555d267 in server_process_turn_allocate (server=0x555555582500, msg=0x7ffff7d370f0, src=0x7ffff7d37d20, credentials=0x555555583570)
at /opt/violet_src/deps/libjuice/src/server.c:868
#4 0x000055555555c5cc in server_dispatch_stun (server=0x555555582500, buf=0x7ffff7d37db0, size=124, msg=0x7ffff7d370f0, src=0x7ffff7d37d20)
at /opt/violet_src/deps/libjuice/src/server.c:671
#5 0x000055555555b9d1 in server_input (server=0x555555582500, buf=0x7ffff7d37db0 "", len=124, src=0x7ffff7d37d20) at /opt/violet_src/deps/libjuice/src/server.c:474
#6 0x000055555555b44b in server_recv (server=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:402
#7 0x000055555555b0ba in server_run (server=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:348
#8 0x000055555555a2bb in server_thread_entry (arg=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:111
#9 0x00007ffff7fa6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007ffff7ecd293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
And here is the configuration file that I used:
log-level=debug
# Port for STUN/TURN server
port=8000
# Port range for TURN relay
range=49152:65535
# TURN credentials with optional quota (default none)
credentials=user:password
Thank you for your work by the way.