ITADN

SIGSEGV on FreeBSD

#99Openbulatovv 创建于 2026-01-08
B
bulatovvcommented
`microsocks` crashes with SIGSEGV on FreeBSD because the default `THREAD_STACK_SIZE` (32KB) is insufficient when `getaddrinfo` triggers logging. The crash occurs when `getaddrinfo` encounters a DNS anomaly (e.g., hostname mismatch) and attempts to log it via `syslog`. The call chain `getaddrinfo` -> `nsdispatch` -> `syslog` -> `vfprintf` consumes more stack space than available, leading to a stack overflow. ``` * thread #1, name = 'microsocks', stop reason = signal SIGSEGV * frame #0: 0x00000008229fbf87 libc.so.7`___lldb_unnamed_symbol4967 + 23 frame #1: 0x00000008229fbd5b libc.so.7`vfprintf_l + 187 frame #2: 0x00000008229f478f libc.so.7`fprintf + 191 frame #3: 0x0000000822993588 libc.so.7`___lldb_unnamed_symbol4408 + 216 frame #4: 0x00000008229933d6 libc.so.7`syslog + 214 frame #5: 0x00000008229bbd5f libc.so.7`___lldb_unnamed_symbol4630 + 1023 frame #6: 0x00000008229bb0d3 libc.so.7`___lldb_unnamed_symbol4627 + 1091 frame #7: 0x00000008229cb72d libc.so.7`_nsdispatch + 1437 frame #8: 0x00000008229b94a8 libc.so.7`___lldb_unnamed_symbol4616 + 120 frame #9: 0x00000008229b9016 libc.so.7`getaddrinfo + 2870 frame #10: 0x00000000002045a8 microsocks`resolve(host="alive.github.com", port=443, addr=0x0000000828c40a08) at server.c:14:9 frame #11: 0x000000000020409e microsocks`connect_socks_target(buf="\U00000005\U00000001", n=23, client=0x00000326d661a218) at sockssrv.c:162:5 ``` Increasing `THREAD_STACK_SIZE` to 64KB for FreeBSD fixes the issue. After recompiling with the increased stack size, the process no longer segfaults. DNS anomalies are successfully logged to `/var/log/messages`. ``` Jan 8 19:27:00 vps0 microsocks[1338]: gethostby*.getanswer: asked for "lh3.googleusercontent.com", got "googlehosted.l.googleusercontent.com" Jan 8 19:29:40 vps0 microsocks[1338]: gethostby*.getanswer: asked for "alive.github.com", got "live.github.com" ``` Environment: **OS:** FreeBSD 14.2-RELEASE amd64 **Microsocks versions:** v1.0.5, v1.0.4
1 条评论