• src/sbbs3/js_internal.cpp

    From Rob Swindell (on Windows@VERT to Git commit to main/sbbs/m on Sun Oct 25 13:37:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/2c1ce331e85657a9c3765f80
    Modified Files:
    src/sbbs3/js_internal.cpp js_socket.cpp
    Log Message:
    js: release asynchronous connect resources on setup failure and clear

    Socket.connect() with a callback linked and GC-rooted the connect event
    before allocating the thread's argument block and copying the hostname.
    When either allocation failed, the function closed the socket pair and
    returned an error, but left the event in the list pointing at the closed descriptors, so the next event-loop pass selected on them. Allocate the
    thread arguments first; the event is only linked once nothing after it
    can fail.

    Clearing all pending events freed a pending connect event without
    closing its socket pair's read end, leaking a descriptor each time a
    script ended with an asynchronous connect in flight.

    Both date from 1928973941 (2021-04-02).

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
  • From Rob Swindell (on Windows@VERT to Git commit to main/sbbs/m on Mon Nov 9 21:51:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/8b27c9a760f0e1902c11a58b
    Modified Files:
    src/sbbs3/js_internal.cpp
    Log Message:
    js: clear events that exit handlers register; don't abort on early timeout

    js_handle_events() clears the event list, run queue and listeners when the
    loop ends, but the host then runs the script's js.on_exit() handlers, and anything those register was left in the js_callback_t (the ircd queues js.setImmediate() callbacks while announcing its shutdown). Each entry
    roots its callback and "this" object, which kept the script's global
    object, and every socket reachable from it, alive after the context was destroyed. Where the host re-runs the script with the same js_callback_t (jsexec -l, static-loop services) the next run also dispatched the stale entries.

    js_EvalOnExit() now clears them after running the global scope's handlers. js.exec() runs a child script's handlers through a static helper instead,
    so that it cannot clear its caller's events. The terminal server runs each script in its own scope and is not covered (#1332).

    Since the clock refresh added in 2074253fa1 (2026-10-28), js_handle_events() aborts the script with "poll() returned ready, but didn't find anything" if
    the wait times out before the earliest timer is due by xp_timer()'s clock.
    It now waits again. That has not been observed to happen; it is the only
    path found to that error when no descriptor is ready.

    The error itself now reports the wait's return value, its timeout and the
    time remaining to the next timer.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Wed Nov 11 21:04:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/7be788832e05bcb64ff846de
    Modified Files:
    src/sbbs3/js_internal.cpp
    Log Message:
    js: don't write an int through the bool* behind js.terminated

    The js.terminated setter passed (int *)cb->terminated to
    JS_ValueToBoolean(), which stores a 4-byte JSBool. cb->terminated has
    pointed at a 1-byte bool since the BOOL->bool conversion in 118984e9af (soil-11-pick, 2024-01-19); the cast, written when it pointed at a BOOL,
    kept the compiler from flagging the mismatch. Every assignment to
    js.terminated therefore also overwrote the 3 bytes following the host's
    flag; in jsexec that is the 'recycled' global.

    Convert into a local JSBool and assign that instead, and propagate a
    conversion failure like the other setters.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>