Environment
- OS: macOS (Intel x86_64)
- Version: Sequoia 15.7.3
- Tool: tpws from zapret
The Problem
When running tpws on macOS, the program crashes with a bus error (EXC_BAD_ACCESS) as soon as a connection is received and a DNS lookup is triggered through the resolver thread.
Backtrace Analysis
Debugging with lldb revealed that the crash occurs within libswiftCore.dylib during a getaddrinfo call. On modern macOS, standard C networking functions often trigger the Swift runtime. The default stack size for the resolver thread in resolver.c is set to 32KB (PTHREAD_STACK_MIN > 32768 ? PTHREAD_STACK_MIN : 32768). This is insufficient for the Swift-heavy system libraries on macOS, leading to a stack overflow.
* thread #2, stop reason = EXC_BAD_ACCESS (code=2, address=...)
frame #0: 0x... libswiftCore.dylib`swift::SubstGenericParametersFromMetadata::setup() const + 50
...
frame #57: 0x... libsystem_info.dylib`getaddrinfo + 185
frame #58: 0x... tpws`resolver_thread(arg=...) at resolver.c:103:18
Proposed Solution
Increasing the thread stack size in resolver.c from 32KB to 1MB fixes the issue and restores stability.
// Suggested change in resolver.c
if (pthread_attr_setstacksize(&attr, 1024 * 1024)) { ... }
I have verified that this change resolves the bus error on my Intel Mac.
Note: This technical analysis and report were generated with AI assistance. I am a non-expert user who discovered and verified this fix through debugging
Environment
The Problem
When running tpws on macOS, the program crashes with a bus error (EXC_BAD_ACCESS) as soon as a connection is received and a DNS lookup is triggered through the resolver thread.
Backtrace Analysis
Debugging with lldb revealed that the crash occurs within libswiftCore.dylib during a getaddrinfo call. On modern macOS, standard C networking functions often trigger the Swift runtime. The default stack size for the resolver thread in resolver.c is set to 32KB (PTHREAD_STACK_MIN > 32768 ? PTHREAD_STACK_MIN : 32768). This is insufficient for the Swift-heavy system libraries on macOS, leading to a stack overflow.
Proposed Solution
Increasing the thread stack size in resolver.c from 32KB to 1MB fixes the issue and restores stability.
I have verified that this change resolves the bus error on my Intel Mac.
Note: This technical analysis and report were generated with AI assistance. I am a non-expert user who discovered and verified this fix through debugging