If smux is hanging during startup after the format string changes in window-tree.c, follow these steps:
cd /home/alejandro/Swarm/smux
./quick-debug-hang.shThis will:
- Test if smux hangs on
new-session - If hung, attach GDB and get backtrace
- Show last system calls with strace
- Identify if hang is in format parsing code
cd /home/alejandro/Swarm/smux
./debug-startup-hang.shThis will:
- Rebuild with debug symbols
- Run strace to capture system calls
- Run GDB with breakpoints on format functions
- Test with reverted format string
- Generate detailed logs
cd /home/alejandro/Swarm/smux
patch -p1 < add-debug-logging.patch
make clean && CFLAGS="-g -O0" make
./smux -vvv new-session -d -s debug-testCheck /tmp/smux-server-*.log for detailed format parsing logs.
If you want to manually debug:
# Terminal 1: Start smux under GDB
gdb -x debug-format-parsing.gdb ./smux
# The script will automatically set breakpoints and run
# Watch for:
# - "PARSING 'default' keyword" messages
# - Recursion count warnings
# - Infinite loop detectionBefore (working):
"#[fg=#E6A95E,bold]SESSION #[fg=#BFBDB6]#[bold]🖥️ #{session_name}#[nobold] "
After (potentially hanging):
"#[fg=#E6A95E,bold]SESSION #[default]#[fg=#BFBDB6]🖥️ #{session_name} "
#[nobold]- Only clears the BOLD attribute, leaves colors intact#[default]- Resets ALL attributes (colors, bold, etc.) to base defaults
- State Reset Issue:
#[default]resets to base state which might be uninitialized - Circular Reference: Resetting to default might trigger re-parsing of the format
- Performance: Multiple rapid style changes might have O(n²) complexity
- Edge Case: The sequence
#[bold]#[default]#[color]might hit an untested code path
If you see repeated calls to these functions, it's infinite recursion:
format_expandformat_expand1style_parseformat_draw
If you see the process stuck on:
poll()orselect()→ Waiting for I/O (not CPU bound)- No syscalls → CPU-bound infinite loop
- Repeated
brk()→ Memory allocation loop
Look for:
- Same format string being expanded multiple times
current_defaultvalues changing unexpectedly- Errors in style parsing
cd /home/alejandro/Swarm/smux
# Edit window-tree.c line 65:
# Change:
"#[fg=#E6A95E,bold]SESSION #[default]#[fg=#BFBDB6]🖥️ #{session_name} "
# To:
"#[fg=#E6A95E,bold]SESSION #[fg=#BFBDB6]#[bold]🖥️ #{session_name}#[nobold] "
make clean && make# Edit window-tree.c line 65:
# Change:
"#[fg=#E6A95E,bold]SESSION #[default]#[fg=#BFBDB6]🖥️ #{session_name} "
# To:
"#[fg=#E6A95E,bold]SESSION #[nobold]#[fg=#BFBDB6]🖥️ #{session_name} "
make clean && makeThis achieves the same visual result (removing redundant #[bold]) without using #[default].
If you identify the actual bug:
- Add null checks in
style_parse()for base parameter - Add recursion depth limit in
format_expand() - Optimize style state management in
format_draw() - Add validation for
#[default]in format strings
After applying a fix:
# Test basic functionality
./smux new-session -d -s test1 && echo "✓ new-session works"
./smux new-project -d testproj && echo "✓ new-project works"
./smux choose-tree -s && echo "✓ choose-tree works"
# Test format rendering
./smux list-sessions -F "#{session_name}"
./smux list-projects
# Kill test sessions
./smux kill-session -t test1
./smux kill-session -t testproj-0After running debug scripts, check these files:
/tmp/smux-startup.log- Verbose startup log/tmp/smux-strace.log- System call trace/tmp/gdb-output.log- GDB debugging output/tmp/smux-format-debug.log- Format parsing details/tmp/hang-backtrace.log- Backtrace if hung
If you confirm the hang, report with:
- Exact command that hangs: e.g.,
smux new-session -d -s test - Time to hang: How long before it gets stuck
- Backtrace: From
/tmp/hang-backtrace.log - Last syscalls: From
/tmp/hang-strace.log - Environment: Number of existing sessions/projects
- Terminal type: $TERM variable
// In format-draw.c, line 826:
fprintf(stderr, "DEBUG: Parsing style: %s\n", tmp);
fflush(stderr);
// In style.c, line 87:
fprintf(stderr, "DEBUG: Reset to default, base->fg=%d\n", base->fg);
fflush(stderr);valgrind --leak-check=full --track-origins=yes --log-file=/tmp/valgrind.log \
./smux new-session -d -s valgrind-testperf record -g ./smux new-session -d -s perf-test
perf reportIf you need help:
- Share log files from
/tmp/ - Include output of
./quick-debug-hang.sh - Describe your environment (sessions/projects count)