gjedeer / tuntox

Tunnel TCP connections over the Tox protocol
https://gdr.name/tuntox/
Other
343 stars 57 forks source link

Error in server mode #50

Closed dcapeletti closed 6 years ago

dcapeletti commented 6 years ago

After using a tuntox client connected to port 22 of the tuntox server for several minutes, the following error occurs on the server


Created a new tunnel object connid=61202 sockfd=11
2018-01-29 12:21:23: [WARNING]  conn closed!
2018-01-29 12:21:23: [INFO] Deleting tunnel #61202 ptr 0x1b2f060
2018-01-29 12:21:23: [INFO] Deleting tunnel #0 ptr 0x1b2f060
*** Error in `/home/username/.tuntox/./tuntox-x64': double free or corruption (fasttop): 0x0000000001b2f060 ***
======= Backtrace: =========
[0x476581]
[0x47eac6]
[0x482af7]
[0x403f76]
[0x406d37]
[0x40822b]
[0x4568b6]
[0x456aaa]
[0x400929]
======= Memory map: ========
00400000-0054c000 r-xp 00000000 08:06 23082910                           /home/username/.tuntox/tuntox-x64
0074b000-00750000 rw-p 0014b000 08:06 23082910                           /home/username/.tuntox/tuntox-x64
00750000-00757000 rw-p 00000000 00:00 0 
01adc000-01b4f000 rw-p 00000000 00:00 0                                  [heap]
7f383c000000-7f383c025000 rw-p 00000000 00:00 0 
7f383c025000-7f3840000000 ---p 00000000 00:00 0 
7f38412c6000-7f38419f1000 rw-p 00000000 00:00 0 
7ffe65745000-7ffe6576a000 rw-p 00000000 00:00 0                          [stack]
7ffe657e2000-7ffe657e4000 r--p 00000000 00:00 0                          [vvar]
7ffe657e4000-7ffe657e6000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
./Enlace hacia Soporte remoto: línea 3: 11095 Violación de segmento  /home/username/.tuntox/./tuntox-x64 -C /home/username/.tuntox/ -s "soporte123456789"

There is no error in the client mode.

dcapeletti commented 6 years ago
2018-01-29 14:59:47: [WARNING]  conn closed!
2018-01-29 14:59:47: [INFO] Deleting tunnel #14286 ptr 0xa74280
2018-01-29 14:59:47: [INFO] Deleting tunnel #35707 ptr 0xabe320
2018-01-29 14:59:47: [INFO] Deleting tunnel #63009 ptr 0xab7660
2018-01-29 14:59:47: [INFO] Deleting tunnel #0 ptr 0xab7660
./Enlace hacia Soporte remoto: línea 3: 22800 Violación de segmento /home/username/.tuntox/./tuntox-x64 -C /home/username/.tuntox/ -s "soporte123456789"

This is another error, the server closes but without detail.

gjedeer commented 6 years ago

Thanks! Any sure way to reproduce maybe?

Also do you know how to build from source and/or use gdb?

On January 29, 2018 7:08:49 PM GMT+01:00, Diego Ariel Capeletti notifications@github.com wrote:

2018-01-29 14:59:47: [WARNING] conn closed!
2018-01-29 14:59:47: [INFO]    Deleting tunnel #14286 ptr 0xa74280
2018-01-29 14:59:47: [INFO]    Deleting tunnel #35707 ptr 0xabe320
2018-01-29 14:59:47: [INFO]    Deleting tunnel #63009 ptr 0xab7660
2018-01-29 14:59:47: [INFO]    Deleting tunnel #0 ptr 0xab7660
./Enlace hacia Soporte remoto: línea 3: 22800 Violación de segmento
/home/username/.tuntox/./tuntox-x64 -C /home/username/.tuntox/ -s
"soporte123456789"

This is another error, the server closes but without detail.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/gjedeer/tuntox/issues/50#issuecomment-361333903

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

dcapeletti commented 6 years ago

I'm pretty sure I know how to reproduce it. I will try to build it following this file https://github.com/gjedeer/tuntox/blob/master/BUILD.md Thanks!

gjedeer commented 6 years ago

Awesome. Here's how to generate a nice backtrace for me:

https://wiki.ubuntu.com/Backtrace#Generation

On January 29, 2018 7:23:21 PM GMT+01:00, Diego Ariel Capeletti notifications@github.com wrote:

I'm pretty sure I know how to reproduce it. I will try to build it following this file https://github.com/gjedeer/tuntox/blob/master/BUILD.md Thanks!

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/gjedeer/tuntox/issues/50#issuecomment-361338273

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

dcapeletti commented 6 years ago

If you give me a hand, I can move on. I have already compiled and installed c-toxcore successfully, but I have the following problem when building tuntox. I'm in debian 9.3

$ make
  GEN   gitversion.h
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    log.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    client.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    gitversion.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    mach.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    main.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
  CC    util.o
Package libevent_pthreads was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent_pthreads.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libevent_pthreads' found
gcc -o tuntox log.o client.o gitversion.o mach.o main.o util.o -lpthread -g -pthread -lm -static -lrt  
main.o: En la función `do_daemonize':
/home/dcapeletti/tuntox/main.c:1091: aviso: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
client.o: En la función `local_bind':
/home/dcapeletti/tuntox/client.c:61: aviso: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
client.o: En la función `do_client_loop':
/home/dcapeletti/tuntox/client.c:273: referencia a `tox_callback_friend_lossless_packet' sin definir
/home/dcapeletti/tuntox/client.c:292: referencia a `tox_iterate' sin definir
/home/dcapeletti/tuntox/client.c:328: referencia a `tox_friend_add' sin definir
/home/dcapeletti/tuntox/client.c:353: referencia a `tox_friend_get_connection_status' sin definir
/home/dcapeletti/tuntox/client.c:373: referencia a `tox_friend_delete' sin definir
/home/dcapeletti/tuntox/client.c:412: referencia a `tox_friend_send_lossless_packet' sin definir
/home/dcapeletti/tuntox/client.c:580: referencia a `tox_iteration_interval' sin definir
main.o: En la función `do_bootstrap':
/home/dcapeletti/tuntox/main.c:188: referencia a `tox_bootstrap' sin definir
/home/dcapeletti/tuntox/main.c:189: referencia a `tox_add_tcp_relay' sin definir
main.o: En la función `set_tox_username':
/home/dcapeletti/tuntox/main.c:204: referencia a `tox_self_set_name' sin definir
main.o: En la función `send_frame':
/home/dcapeletti/tuntox/main.c:319: referencia a `tox_friend_send_lossless_packet' sin definir
/home/dcapeletti/tuntox/main.c:354: referencia a `tox_iterate' sin definir
main.o: En la función `write_save':
/home/dcapeletti/tuntox/main.c:705: referencia a `tox_get_savedata_size' sin definir
/home/dcapeletti/tuntox/main.c:707: referencia a `tox_get_savedata' sin definir
main.o: En la función `accept_friend_request':
/home/dcapeletti/tuntox/main.c:883: referencia a `tox_friend_add_norequest' sin definir
main.o: En la función `cleanup':
/home/dcapeletti/tuntox/main.c:906: referencia a `tox_kill' sin definir
main.o: En la función `do_server_loop':
/home/dcapeletti/tuntox/main.c:926: referencia a `tox_callback_friend_lossless_packet' sin definir
/home/dcapeletti/tuntox/main.c:941: referencia a `tox_iterate' sin definir
/home/dcapeletti/tuntox/main.c:944: referencia a `tox_iteration_interval' sin definir
main.o: En la función `main':
/home/dcapeletti/tuntox/main.c:1448: referencia a `tox_options_default' sin definir
/home/dcapeletti/tuntox/main.c:1477: referencia a `tox_new' sin definir
/home/dcapeletti/tuntox/main.c:1481: referencia a `tox_new' sin definir
/home/dcapeletti/tuntox/main.c:1484: referencia a `tox_new' sin definir
/home/dcapeletti/tuntox/main.c:1487: referencia a `tox_new' sin definir
/home/dcapeletti/tuntox/main.c:1502: referencia a `tox_callback_self_connection_status' sin definir
/home/dcapeletti/tuntox/main.c:1508: referencia a `tox_self_get_address' sin definir
/home/dcapeletti/tuntox/main.c:1529: referencia a `tox_self_get_address' sin definir
/home/dcapeletti/tuntox/main.c:1535: referencia a `tox_callback_friend_request' sin definir
collect2: error: ld returned 1 exit status
Makefile:30: fallo en las instrucciones para el objetivo 'tuntox'
make: *** [tuntox] Error 1
username@debian-server:~/tuntox$ 

I have libevent-pthreads-2.0-5 installed

dcapeletti commented 6 years ago

Excuse me, that problem is solved but I have a new one.


$ make
  GEN   gitversion.h
  CC    log.o
  CC    client.o
  CC    gitversion.o
  CC    mach.o
  CC    main.o
  CC    util.o
gcc -o tuntox log.o client.o gitversion.o mach.o main.o util.o -lpthread -g -pthread -lm -static -lrt -ltoxdns -ltoxencryptsave -ltoxcore -lsodium -lm -lpthread -lsodium -levent_pthreads -levent 
/usr/bin/ld: no se puede encontrar -ltoxencryptsave
main.o: En la función `do_daemonize':
/home/dcapeletti/tuntox/main.c:1091: aviso: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
client.o: En la función `local_bind':
/home/dcapeletti/tuntox/client.c:61: aviso: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Makefile:30: fallo en las instrucciones para el objetivo 'tuntox'
make: *** [tuntox] Error 1
dcapeletti commented 6 years ago

I've solved it with make tuntox_nostatic

dcapeletti commented 6 years ago

Well, I think I finally got something useful.

GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./tuntox_nostatic...done.
(gdb) RUNrun
Starting program: /home/dcapeletti/tuntox/tuntox_nostatic -C /home/dcapeletti/.tuntox/ -s soporte\ trillis
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
2018-01-29 22:24:27: [INFO] Tuntox built from git commit b8c2242cafe33bda19c9774e2584be7508cb35f0
2018-01-29 22:24:27: [INFO] Using 17621 for TCP relay port and 54415-54425 for UDP
2018-01-29 22:24:27: [INFO] Using Tox ID: 6A27CF7A7DD03F9C05B89B02AE30EFCB2282D8F02E0EF9F669E7BE643A93154F3A1720F8F76A
2018-01-29 22:24:37: [INFO] Connection status changed: An UDP connection has been established
2018-01-29 22:24:57: [INFO] Accepted friend request from 9C414B8AEB9CA21D8D19E78DE2BF4F3D7C34FEB50486E911E14E12B7D66ACE77F7C376FB92DC as 0
2018-01-29 22:26:00: [INFO] Got a request to forward data from 127.0.0.1:22
2018-01-29 22:26:00: [INFO] Created a new tunnel object connid=1159 sockfd=9
2018-01-29 22:26:13: [INFO] Got a request to forward data from 127.0.0.1:22
2018-01-29 22:26:13: [INFO] Created a new tunnel object connid=49676 sockfd=10
2018-01-29 22:26:14: [INFO] Got a request to forward data from 127.0.0.1:22
2018-01-29 22:26:14: [INFO] Created a new tunnel object connid=35554 sockfd=11
2018-01-29 22:27:50: [WARNING]  conn closed!
2018-01-29 22:27:50: [INFO] Deleting tunnel #1159 ptr 0x5555557abd40
2018-01-29 22:27:50: [INFO] Deleting tunnel #49676 ptr 0x55555579cd00
2018-01-29 22:27:50: [INFO] Deleting tunnel #35554 ptr 0x5555557654b0
2018-01-29 22:27:50: [INFO] Deleting tunnel #21845 ptr 0x5555557654b0

Program received signal SIGSEGV, Segmentation fault.
0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at main.c:158
158         FD_CLR(t->sockfd, &master_server_fds);
(gdb) 
(gdb) backtrace full
#0  0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at main.c:158
No locals.
#1  0x000055555555d2aa in do_server_loop () at main.c:1045
        tunnel_list_entry = 0x555555766250
        list_tmp = 0x0
        tmp_isconnected = TOX_CONNECTION_UDP
        tox_do_interval_ms = 50
        select_rv = 1
        tv = {tv_sec = 0, tv_usec = 44433}
        tv_start = {tv_sec = 1517275670, tv_usec = 612892}
        tv_end = {tv_sec = 1517275670, tv_usec = 612563}
        ms_start = 1517275670562
        ms_end = 1517275670612
        fds = {__fds_bits = {2048, 0 <repeats 15 times>}}
        tox_packet_buf = "\242j\006\000\004\207\000\214\002\330\032\224uX\267ҽg\334\001\243\251\207\031J\343\237;s\242\375>Y\004\001\336\300Ȧ\356\033k\201k\307t\350\271\032a\202\v\237\330\020\364X\337\313Wf\037\230\273\230\214\223ۭ\363\334\001\300`!\304\017\273%([\230\271\376\254\317i|\207\034\270\375\357\202@\353\245ˀ\312gɫ\262\255ɚ#\334\066H\210\322\035\253=$\005\220@\357\025x\033\266\267Щ\314?j͙\247\035T\345\340\303w\271(Qk\254\270\362\234\342\312QVC\377\377+\000E\355\241\312\377\021\227\241{v\346\232/c\362^\320\004\320}pD\\\215Ȗ5\257S,\371п\220\023\346\311n\326F]\321i\265\267A\366\332u\225j\216`"...
        tun = 0x0
        tmp = 0x0
        connected = TOX_CONNECTION_UDP
        sent_data = 1
#2  0x000055555555e7e3 in main (argc=5, argv=0x7fffffffe228) at main.c:1536
        tox_id = "j'\317z}\320?\234\005\270\233\002\256\060\357\313\"\202\330\360.\016\371\366i\347\276d:\223\025O:\027 \370\367j"
        tox_printable_id = "6A27CF7A7DD03F9C05B89B02AE30EFCB2282D8F02E0EF9F669E7BE643A93154F3A1720F8F76A"
        tox_new_err = TOX_ERR_NEW_OK
        oc = -1
        save_size = 990
        save_data = 0x555555765300 "\370\214\233\366\377\177"
        allowed_toxid_obj = 0x0
(gdb) info registers
rax            0x555555764220   93824994394656
rbx            0x7fffffffe541   140737488348481
rcx            0xffffffffffffff98   -104
rdx            0xaaf39f8    179255800
rsi            0x155e73f    22406975
rdi            0x5579cfc0   1434046400
rbp            0x7fffffffe140   0x7fffffffe140
rsp            0x7fffffffe060   0x7fffffffe060
r8             0x7ffff7fd1700   140737353946880
r9             0x46 70
r10            0x78 120
r11            0x246    582
r12            0x555555557160   93824992244064
r13            0x7fffffffe220   140737488347680
r14            0x0  0
r15            0x0  0
rip            0x55555555e7e3   0x55555555e7e3 <main+3127>
eflags         0x10206  [ PF IF RF ]
cs             0x33 51
ss             0x2b 43
ds             0x0  0
es             0x0  0
fs             0x0  0
gs             0x0  0
(gdb) thread apply all backtrace

Thread 1 (Thread 0x7ffff7fd1700 (LWP 12484)):
#0  0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at main.c:158
#1  0x000055555555d2aa in do_server_loop () at main.c:1045
#2  0x000055555555e7e3 in main (argc=5, argv=0x7fffffffe228) at main.c:1536
(gdb) quit
A debugging session is active.

    Inferior 1 [process 12484] will be killed.

Quit anyway? (y or n) y

The output dgb is attached. gdb-tuntox.txt

Thanks.

gjedeer commented 6 years ago

Thanks a lot. So in terms of reproducing, you've been forwarding 3 ssh connections concurrently, then the ssh server was shut down, correct?

On January 30, 2018 2:33:22 AM GMT+01:00, Diego Ariel Capeletti notifications@github.com wrote:

Well, I think I finally got something useful.


GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./tuntox_nostatic...done.
(gdb) RUNrun
Starting program: /home/dcapeletti/tuntox/tuntox_nostatic -C
/home/dcapeletti/.tuntox/ -s soporte\ trillis
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
2018-01-29 22:24:27: [INFO]    Tuntox built from git commit
b8c2242cafe33bda19c9774e2584be7508cb35f0
2018-01-29 22:24:27: [INFO]    Using 17621 for TCP relay port and
54415-54425 for UDP
2018-01-29 22:24:27: [INFO]    Using Tox ID:
6A27CF7A7DD03F9C05B89B02AE30EFCB2282D8F02E0EF9F669E7BE643A93154F3A1720F8F76A
2018-01-29 22:24:37: [INFO]    Connection status changed: An UDP
connection has been established
2018-01-29 22:24:57: [INFO]    Accepted friend request from
9C414B8AEB9CA21D8D19E78DE2BF4F3D7C34FEB50486E911E14E12B7D66ACE77F7C376FB92DC
as 0
2018-01-29 22:26:00: [INFO]    Got a request to forward data from
127.0.0.1:22
2018-01-29 22:26:00: [INFO]    Created a new tunnel object connid=1159
sockfd=9
2018-01-29 22:26:13: [INFO]    Got a request to forward data from
127.0.0.1:22
2018-01-29 22:26:13: [INFO]    Created a new tunnel object connid=49676
sockfd=10
2018-01-29 22:26:14: [INFO]    Got a request to forward data from
127.0.0.1:22
2018-01-29 22:26:14: [INFO]    Created a new tunnel object connid=35554
sockfd=11
2018-01-29 22:27:50: [WARNING] conn closed!
2018-01-29 22:27:50: [INFO]    Deleting tunnel #1159 ptr 0x5555557abd40
2018-01-29 22:27:50: [INFO]    Deleting tunnel #49676 ptr 0x55555579cd00
2018-01-29 22:27:50: [INFO]    Deleting tunnel #35554 ptr 0x5555557654b0
2018-01-29 22:27:50: [INFO]    Deleting tunnel #21845 ptr 0x5555557654b0

Program received signal SIGSEGV, Segmentation fault.
0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at main.c:158
158            FD_CLR(t->sockfd, &master_server_fds);
(gdb) 
(gdb) backtrace full
#0  0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at
main.c:158
No locals.
#1  0x000055555555d2aa in do_server_loop () at main.c:1045
       tunnel_list_entry = 0x555555766250
       list_tmp = 0x0
       tmp_isconnected = TOX_CONNECTION_UDP
       tox_do_interval_ms = 50
       select_rv = 1
       tv = {tv_sec = 0, tv_usec = 44433}
       tv_start = {tv_sec = 1517275670, tv_usec = 612892}
       tv_end = {tv_sec = 1517275670, tv_usec = 612563}
       ms_start = 1517275670562
       ms_end = 1517275670612
       fds = {__fds_bits = {2048, 0 <repeats 15 times>}}
tox_packet_buf =
"\242j\006\000\004\207\000\214\002\330\032\224uX\267ҽg\334\001\243\251\207\031J\343\237;s\242\375>Y\004\001\336\300Ȧ\356\033k\201k\307t\350\271\032a\202\v\237\330\020\364X\337\313Wf\037\230\273\230\214\223ۭ\363\334\001\300`!\304\017\273%([\230\271\376\254\317i|\207\034\270\375\357\202@\353\245ˀ\312gɫ\262\255ɚ#\334\066H\210\322\035\253=$\005\220@\357\025x\033\266\267Щ\314?j͙\247\035T\345\340\303w\271(Qk\254\270\362\234\342\312QVC\377\377+\000E\355\241\312\377\021\227\241{v\346\232/c\362^\320\004\320}pD\\\215Ȗ5\257S,\371п\220\023\346\311n\326F]\321i\265\267A\366\332u\225j\216`"...
       tun = 0x0
       tmp = 0x0
       connected = TOX_CONNECTION_UDP
       sent_data = 1
#2  0x000055555555e7e3 in main (argc=5, argv=0x7fffffffe228) at
main.c:1536
tox_id =
"j'\317z}\320?\234\005\270\233\002\256\060\357\313\"\202\330\360.\016\371\366i\347\276d:\223\025O:\027
\370\367j"
tox_printable_id =
"6A27CF7A7DD03F9C05B89B02AE30EFCB2282D8F02E0EF9F669E7BE643A93154F3A1720F8F76A"
       tox_new_err = TOX_ERR_NEW_OK
       oc = -1
       save_size = 990
       save_data = 0x555555765300 "\370\214\233\366\377\177"
       allowed_toxid_obj = 0x0
(gdb) info registers
rax            0x555555764220  93824994394656
rbx            0x7fffffffe541  140737488348481
rcx            0xffffffffffffff98  -104
rdx            0xaaf39f8   179255800
rsi            0x155e73f   22406975
rdi            0x5579cfc0  1434046400
rbp            0x7fffffffe140  0x7fffffffe140
rsp            0x7fffffffe060  0x7fffffffe060
r8             0x7ffff7fd1700  140737353946880
r9             0x46    70
r10            0x78    120
r11            0x246   582
r12            0x555555557160  93824992244064
r13            0x7fffffffe220  140737488347680
r14            0x0 0
r15            0x0 0
rip            0x55555555e7e3  0x55555555e7e3 <main+3127>
eflags         0x10206 [ PF IF RF ]
cs             0x33    51
ss             0x2b    43
ds             0x0 0
es             0x0 0
fs             0x0 0
gs             0x0 0
(gdb) thread apply all backtrace
[gdb-tuntox.txt](https://github.com/gjedeer/tuntox/files/1675935/gdb-tuntox.txt)

Thread 1 (Thread 0x7ffff7fd1700 (LWP 12484)):
#0  0x000055555555a53e in tunnel_delete (t=0x5555557654b0) at
main.c:158
#1  0x000055555555d2aa in do_server_loop () at main.c:1045
#2  0x000055555555e7e3 in main (argc=5, argv=0x7fffffffe228) at
main.c:1536
(gdb) quit
A debugging session is active.

  Inferior 1 [process 12484] will be killed.

Quit anyway? (y or n) y

The output dgb is attached. Thanks.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/gjedeer/tuntox/issues/50#issuecomment-361446958

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

gjedeer commented 6 years ago

I just tried the scenario i described above and no crash. Also running a few SSH sessions for several minutes doesn't seem to crash it.

I see it's a double-free but can't figure out how it's happening. Maybe running with -d -d will give more data.

dcapeletti commented 6 years ago

I explain step by step how I managed to cause the error.

Among the basic features of x2go, is that traffic is safe because it is sent over SSH. See https://wiki.x2go.org/doku.php/doc:newtox2go

dcapeletti commented 6 years ago

Well, I tried to open 3 ssh sessions in three terminals, I work them a bit and when I press Ctrl + D to close the connection in the first or second terminal, the tuntox server has a problem. The gdb output is attached. The ssh server never closes.

gdb-tuntox-terminal-ssh.txt

dcapeletti commented 6 years ago

Attached output gbd of tuntox server mode using the -d option. One output corresponds to the x2go connection and another output corresponds to the use of 3 ssh terminals that connect to the tuntox server. When Ctrl+D is pressed to close a terminal session, sometimes the first, second or last, the tuntox server has problems.

gdb-tuntox-x2go.txt gdb-tuntox-3-ssh-conections.txt

dcapeletti commented 6 years ago

Video demonstration of the error.

gjedeer commented 6 years ago

Thanks for the detailed reporting, I was able to reproduce the problem and fix it.

Please test by building from git master or using this binary https://w1r3.net/hfxwpu.bin

For future (since you seem to be a frequent user, glad to see that!) - using -d twice (-d -d) generates more useful information for me.

dcapeletti commented 6 years ago

Thank you very much, tuntox is very useful for me, the problem is solved. Next time I will send with the -d -d option. Although it would seem to work a bit slower, this issue can be closed.