• src/ssh/TODO.md src/ssh/test/test_selftest.c

    From Deuc¿@VERT to Git commit to main/sbbs/master on Mon Mar 30 14:17:14 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/233f20f35c09bb106d715bc4
    Modified Files:
    src/ssh/TODO.md src/ssh/test/test_selftest.c
    Log Message:
    Fix selftest race: cleanup while server echo thread still sending

    Two bugs caused segfaults in dssh_self_rsa under ctest -j16:

    1. Server thread handle (thrd_t st) was a stack local lost when an
    ASSERT failed mid-test, so dssh_test_after_each cleanup could not
    join it -- the server thread kept running while the session was freed.

    2. g_active_ctx pointed to a stack-local selftest_ctx whose frame was
    popped on test return. Cleanup's deeper function calls (terminate,
    join, session_cleanup) grew the stack into the old frame, corrupting
    the ctx data and causing a NULL deref in dssh_session_stop.

    Fix: add server_thread/server_thread_active fields to selftest_ctx;
    add selftest_start_thread() helper; restructure selftest_cleanup() to
    snapshot all ctx fields into a local copy before any function calls,
    then terminate both sessions, join the server thread, and finally
    cleanup sessions. All 27 test functions updated.

    Also adds TODO items 104-105 for two distinct test failures observed
    under -j16 that need separate investigation.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deuc¨@VERT to Git commit to main/sbbs/master on Mon Mar 30 14:17:14 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/753b6cf1ff5e8b5cbf210660
    Modified Files:
    src/ssh/TODO.md src/ssh/test/test_selftest.c
    Log Message:
    Fix selftest echo write race: poll for DSSH_POLL_WRITE before first write

    dssh_chan_write is non-blocking by design Ä returns 0 when remote_window
    is 0. Both sides open channels with initial_window=0 then independently
    send WINDOW_ADJUST after setup. Under -j16 contention (especially RSA
    keygen), the server's WINDOW_ADJUST hadn't been processed by the client's
    demux thread before the test wrote, causing ~40% failure rate in
    dssh_self_rsa and dssh_self_mlkem_rsa variants.

    Add dssh_chan_poll(DSSH_POLL_WRITE) before the first write in test_self_exec_echo and test_self_shell_echo, matching the pattern
    already used by test_self_shell_large_data. Make server_echo_thread
    (both instances) use a poll-then-retry write loop to avoid silently
    dropping data on partial writes.

    Also log item 106: intermittent dssh_self_dhgex failure observed once
    under heavy -j16 contention, not yet reproduced.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Mon Mar 30 14:17:14 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/5633d44598b307e390232a37
    Modified Files:
    src/ssh/TODO.md src/ssh/test/test_selftest.c
    Log Message:
    Fix 12 more selftest write-before-window races (closes item 106)

    Same root cause as item 104: client-side dssh_chan_write called before
    the server's WINDOW_ADJUST was processed, so remote_window was still 0
    and the non-blocking write returned 0. Under -j16 contention this
    manifested as ASSERT failures in 3 variants (dssh_self, dssh_self_rsa, dssh_self_mlkem) and a secondary Bus error from use-after-free when the
    server echo thread's stack overwrote the test's popped stack frame.

    Added dssh_chan_poll(DSSH_POLL_WRITE) before the first client-side write
    in 12 test functions. 50 consecutive clean runs under -j16 after fix.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net