Getting core dumped in simple tokio tcp proxy

What I am doing basically opening a connection to my proxy and let it bind to the interface I want and io::copy read and write halves of each connection to each other.
When I try to stress test my server sending around 200 request pulses every now and then I get a core dumped. I am attaching the logs from strace.
My only dependency is tokio 0.3 and theres no unsafe in my codebase

epoll_ctl(5, EPOLL_CTL_ADD, 2009, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=33555594, u64=33555594}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65475), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2011
epoll_ctl(5, EPOLL_CTL_ADD, 2011, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=16779162, u64=16779162}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65476), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2013
epoll_ctl(5, EPOLL_CTL_ADD, 2013, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=16779163, u64=16779163}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65477), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2015
epoll_ctl(5, EPOLL_CTL_ADD, 2015, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=16778853, u64=16778853}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65478), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2018
epoll_ctl(5, EPOLL_CTL_ADD, 2018, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=50332744, u64=50332744}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65479), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2021
epoll_ctl(5, EPOLL_CTL_ADD, 2021, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=33555820, u64=33555820}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65482), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2022
epoll_ctl(5, EPOLL_CTL_ADD, 2022, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=33555811, u64=33555811}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65483), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2024
epoll_ctl(5, EPOLL_CTL_ADD, 2024, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=16779115, u64=16779115}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65484), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2026
epoll_ctl(5, EPOLL_CTL_ADD, 2026, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2017, u64=2017}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65485), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2028
epoll_ctl(5, EPOLL_CTL_ADD, 2028, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2018, u64=2018}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65486), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2029
epoll_ctl(5, EPOLL_CTL_ADD, 2029, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2020, u64=2020}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=785619, tv_nsec=454077877}) = 0
futex(0xf78efd00, FUTEX_WAKE_PRIVATE, 1) = 1
accept4(9, {sa_family=AF_INET, sin_port=htons(65487), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2030
epoll_ctl(5, EPOLL_CTL_ADD, 2030, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2021, u64=2021}}) = 0
accept4(9, {sa_family=AF_INET, sin_port=htons(65488), sin_addr=inet_addr("192.168.5.107")}, [128->16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 2031
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

Seems like it would make sense to open an issue on the tokio repo. A more in-depth description of how this could be reproduced would be great, too.

well thats why I wrote here first because I literally have no clue why this is happening and thought someone might suggest some clue from strace or something ?

Could it be stack overflow? That's one case where safe Rust code can cause a segfault (not unsafely, it hits a guard page after the stack).

It's surprisingly easy to use lots of stack with async code that has large local state. Try changing a bunch of expr.await to Box::pin(expr).await.

2 Likes

here is my entire code which is pretty minimalistic and I seem to get this on raspberry pi only

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.