Closed tbobbera closed 6 months ago
seems most likely related to thread stack size. the DNS resolver in musl 1.2.4 has some new code for TCP based DNS lookup, so maybe it requires more stack than previous versions.
try to change line 50 in socksrv.c from
#define THREAD_STACK_SIZE MAX(8*1024, PTHREAD_STACK_MIN)
to
#define THREAD_STACK_SIZE MAX(12*1024, PTHREAD_STACK_MIN)
thanks for the quick response
12
didn't work but after incrementing it appears to start working at around 16
#define THREAD_STACK_SIZE MAX(16*1024, PTHREAD_STACK_MIN)
cool. please notify me when you're reasonably sure that with 16kb there are no issues anymore (maybe test with some extremely long dns names).
On 16kb
haven't been able to make it seg fault. even after successfully resolving hundreds of unique 253 character length domains at once with curl
+ parallel
thanks, fixed in master.
thank you !
I was trying to build and run
microsocks
in a Docker container and noticed that the server will crash when it attempts to make a DNS resolveYou should be able to replicate in a Docker container like this:
And then spawning a shell and running
microsocks
withgdb
to see the seg faultRunning
microsocks
itself is OK, and it can handle requests to1.1.1.1
etc, but as soon as I hit a domain name withcurl
it'll seg faultI rebuilt with debug flags and ran with
gdb
and got this:This seems to happen on:
musl-1.2.4_git20230717-r4 x86_64 {musl} (MIT) [installed]
alpine
latestI can get it working with
alpine:3.14.3
instead ofalpine:latest
which is likely the version I used 3 years ago when I first made my image That usesmusl-1.2.2
:musl-1.2.2-r5 x86_64 {musl} (MIT) [installed]
The issue happens here: https://github.com/rofl0r/microsocks/blob/655c53d27df0bd69e0ecfa8309ce2940797f3362/server.c#L14 -- I've tried dumping variables etc and everything seems OK based on what
getaddrinfo()
expects.Oddly running
python
in the container and usinggetaddrinfo()
with similar arguments works fine...I'm not a C dev so I'm not sure what else to do other than use another distro/Docker base image to run
microsocks
in. I cannot tell if this is amusl
issue or not.I wonder if anybody else is facing this issue or has some ideas on how to solve this cause I'm curious why this is happening.