ws2_offline: refuse the local computer's name, answer localhost with loopback literals, keep WSAIoctl synchronous (RT-WS2-OFFLINE-LOOKUP-LEAKS) #2533

Merged
Tyrannys merged 3 commits from upstream-pr/2533 into main 2026-11-28 23:25:00 +00:00
Tyrannys commented 2026-11-28 01:10:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T01:10:56Z.


Claimed in the coordination issue as: RT-WS2-OFFLINE-LOOKUP-LEAKS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231475417)

What and why

Item 3 of @kevincommits' batch 18 in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231277215). Thanks for the line-by-line report.

runtime/shims/ws2_offline.cpp is what keeps a title off the network. Three gaps:

  • The local computer's own addresses. is_loopback_node_a/w returned true for a null and an empty name. So getaddrinfo, GetAddrInfoW, GetAddrInfoExA/W, gethostbyname and WSAAsyncGetHostByName passed "" (and, for the last two, NULL) to the host. The host answers those with every address of the local computer: its LAN and external adapters. WSAConnectByNameA/W already refused them.
    • Now an empty name is not loopback, and gethostbyname/WSAAsyncGetHostByName also refuse a null one (WSAHOST_NOT_FOUND).
    • A null getaddrinfo node is still answered: it is a service-only lookup that gives loopback, or with AI_PASSIVE the wildcard, which the shim's bind narrows to loopback.
  • localhost and the hosts file. WSAConnectByNameA/W hand the host the literal 127.0.0.1 for localhost, so the hosts file is never read. The six lookup shims passed the name itself, so a hosts entry could map it off loopback.
    • They now pass a loopback literal too: ::1 for an AF_INET6 lookup, else 127.0.0.1. gethostbyname and WSAAsyncGetHostByName are IPv4 only, so they get 127.0.0.1.
    • An AF_UNSPEC lookup of localhost therefore answers 127.0.0.1 only, where Windows also lists ::1.
  • Overlapped WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER). For WSAID_CONNECTEX and WSAID_WSASENDMSG, the shim passed the caller's overlapped and completion routine to the host, together with &real_ext and &returned in its own stack frame. If the host completed later, it would write into a frame that was gone.
    • The host now writes its pointer and byte count into a small heap block of the shim's (wrap_extension_lookup). The block is freed when the call completes and kept if the host reports it pending.
    • The caller's overlapped and routine still go to the host, so the completion (port packet, event, routine, or nothing for a socket without WSA_FLAG_OVERLAPPED) is reported as Winsock reports it.
    • The wrapper is in the caller's buffer before the host is called, so the caller never sees the native pointer. On failure the buffer gets its old contents back.
  • Under AI_NUMERICHOST, localhost is passed on unchanged, so the host refuses it (EAI_NONAME).

The header comment and docs/runtime_imports.md describe the new rules.

Overlap: #2241 (connect and UDP) and #2242 (WSAConnectByName to localhost on IPv6 sockets) change other functions of this file and test. Whichever lands second may need a small rebase of the test file, which all three append to. With #2242, WSAConnectByName and these lookups pick ::1 the same way: by the socket's or the lookup's family.

Tested

Windows 11, MSVC (VS 18), RelWithDebInfo, on main 431ceba4f. Loopback only, no network.

  • ws2_offline_test gains section 9:
    • gethostbyname(NULL) and gethostbyname(""), WSAAsyncGetHostByName with a null or empty name, getaddrinfo("") and GetAddrInfoW(L"") are refused;
    • getaddrinfo(NULL, "80") is still answered;
    • getaddrinfo("localhost", AF_INET) answers 127.0.0.1 only, getaddrinfo("localhost.", AF_INET6) ::1 only, and gethostbyname("LOCALHOST") loopback only;
    • an overlapped WSAIoctl for ConnectEx returns the same wrapped pointer as a plain one and sets its event;
    • on a completion-port socket, it posts its packet with the wrapped pointer already in the buffer;
    • on a socket without WSA_FLAG_OVERLAPPED, the overlapped ends as the host's own call leaves it;
    • getaddrinfo("localhost", AI_NUMERICHOST) is EAI_NONAME;
    • one for WSASendMsg with a completion routine runs it once at the next alertable wait.
  • With main's shim the test fails at gethostbyname(NULL) (the host answered with this computer's addresses) and then crashes later in section 9. With the fix, 87/87 checks pass (the review's three cases fail with the first version of this PR).
  • scripts/check_no_game_data.py: clean.

Not tested: a hosts file that maps localhost elsewhere (the test does not edit the system's hosts file), and Wine.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5535242957 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T01:10:56Z. --- Claimed in the coordination issue as: RT-WS2-OFFLINE-LOOKUP-LEAKS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231475417) ### What and why Item 3 of @kevincommits' batch 18 in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231277215). Thanks for the line-by-line report. `runtime/shims/ws2_offline.cpp` is what keeps a title off the network. Three gaps: - **The local computer's own addresses.** `is_loopback_node_a/w` returned true for a null *and* an empty name. So `getaddrinfo`, `GetAddrInfoW`, `GetAddrInfoExA/W`, `gethostbyname` and `WSAAsyncGetHostByName` passed `""` (and, for the last two, `NULL`) to the host. The host answers those with every address of the local computer: its LAN and external adapters. `WSAConnectByNameA/W` already refused them. - Now an empty name is not loopback, and `gethostbyname`/`WSAAsyncGetHostByName` also refuse a null one (`WSAHOST_NOT_FOUND`). - A null `getaddrinfo` node is still answered: it is a service-only lookup that gives loopback, or with `AI_PASSIVE` the wildcard, which the shim's `bind` narrows to loopback. - **`localhost` and the hosts file.** `WSAConnectByNameA/W` hand the host the literal `127.0.0.1` for `localhost`, so the hosts file is never read. The six lookup shims passed the name itself, so a hosts entry could map it off loopback. - They now pass a loopback literal too: `::1` for an `AF_INET6` lookup, else `127.0.0.1`. `gethostbyname` and `WSAAsyncGetHostByName` are IPv4 only, so they get `127.0.0.1`. - An `AF_UNSPEC` lookup of `localhost` therefore answers `127.0.0.1` only, where Windows also lists `::1`. - **Overlapped `WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)`.** For `WSAID_CONNECTEX` and `WSAID_WSASENDMSG`, the shim passed the caller's overlapped and completion routine to the host, together with `&real_ext` and `&returned` in its own stack frame. If the host completed later, it would write into a frame that was gone. - The host now writes its pointer and byte count into a small heap block of the shim's (`wrap_extension_lookup`). The block is freed when the call completes and kept if the host reports it pending. - The caller's overlapped and routine still go to the host, so the completion (port packet, event, routine, or nothing for a socket without `WSA_FLAG_OVERLAPPED`) is reported as Winsock reports it. - The wrapper is in the caller's buffer before the host is called, so the caller never sees the native pointer. On failure the buffer gets its old contents back. - Under `AI_NUMERICHOST`, `localhost` is passed on unchanged, so the host refuses it (`EAI_NONAME`). The header comment and `docs/runtime_imports.md` describe the new rules. Overlap: #2241 (`connect` and UDP) and #2242 (`WSAConnectByName` to `localhost` on IPv6 sockets) change other functions of this file and test. Whichever lands second may need a small rebase of the test file, which all three append to. With #2242, `WSAConnectByName` and these lookups pick `::1` the same way: by the socket's or the lookup's family. ### Tested Windows 11, MSVC (VS 18), RelWithDebInfo, on `main` 431ceba4f. Loopback only, no network. - `ws2_offline_test` gains section 9: - `gethostbyname(NULL)` and `gethostbyname("")`, `WSAAsyncGetHostByName` with a null or empty name, `getaddrinfo("")` and `GetAddrInfoW(L"")` are refused; - `getaddrinfo(NULL, "80")` is still answered; - `getaddrinfo("localhost", AF_INET)` answers `127.0.0.1` only, `getaddrinfo("localhost.", AF_INET6)` `::1` only, and `gethostbyname("LOCALHOST")` loopback only; - an overlapped `WSAIoctl` for ConnectEx returns the same wrapped pointer as a plain one and sets its event; - on a completion-port socket, it posts its packet with the wrapped pointer already in the buffer; - on a socket without `WSA_FLAG_OVERLAPPED`, the overlapped ends as the host's own call leaves it; - `getaddrinfo("localhost", AI_NUMERICHOST)` is `EAI_NONAME`; - one for WSASendMsg with a completion routine runs it once at the next alertable wait. - With `main`'s shim the test fails at `gethostbyname(NULL)` (the host answered with this computer's addresses) and then crashes later in section 9. With the fix, 87/87 checks pass (the review's three cases fail with the first version of this PR). - `scripts/check_no_game_data.py`: clean. Not tested: a hosts file that maps `localhost` elsewhere (the test does not edit the system's hosts file), and Wine. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
timbot103 commented 2026-11-28 02:01:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:01:37Z.


Reviewed at head f589998bf on Windows 11 (MSVC 2022 19.44).

Verification

  • Built ws2_offline_test.
  • ws2_offline_test: 83/83 checks passed.

Findings (Request changes)

  1. Synthetic complete_now drops IOCP completions for overlapped sockets (ws2_offline.cpp:851-874, 903-931):
    Both wrapped WSAIoctl GUID handlers pass nullptr, nullptr for overlapped/completion to real_fn and then call complete_now(). For an overlapped socket associated with an I/O completion port where the caller provides an OVERLAPPED without an event or APC routine (and without FILE_SKIP_COMPLETION_PORT_ON_SUCCESS), complete_now() only fills Internal/InternalHigh and posts no IOCP packet, leaving a caller waiting on GetQueuedCompletionStatus hung indefinitely. (The new tests in ws2_offline_test.cpp:601-635 exercise event and APC only.)
  2. Non-overlapped sockets receive completions they must ignore (ws2_offline.cpp:851-874, 903-931):
    complete_now() unconditionally writes *overlapped and signals hEvent or queues an APC whenever overlapped != nullptr, without checking whether s was created with WSA_FLAG_OVERLAPPED. Per the Winsock WSAIoctl contract, both lpOverlapped and lpCompletionRoutine are ignored on non-overlapped sockets.
  3. Minor (ws2_offline.cpp:264-272, 612-668, 858-870):
    • Substituting loopback literals for "localhost" does not check AI_NUMERICHOST first, so getaddrinfo("localhost", ..., AI_NUMERICHOST) can succeed instead of returning EAI_NONAME.
    • In complete_now(), heap-allocating Call for QueueUserAPC leaks if the calling thread exits before entering an alertable wait.

AI-assisted review + local MSVC verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232077692 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7232077692). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:01:37Z. --- Reviewed at head `f589998bf` on Windows 11 (MSVC 2022 `19.44`). ### Verification - Built `ws2_offline_test`. - `ws2_offline_test`: **83/83 checks passed**. ### Findings (Request changes) 1. **Synthetic `complete_now` drops IOCP completions for overlapped sockets (`ws2_offline.cpp:851-874`, `903-931`):** Both wrapped `WSAIoctl` GUID handlers pass `nullptr, nullptr` for `overlapped`/`completion` to `real_fn` and then call `complete_now()`. For an overlapped socket associated with an I/O completion port where the caller provides an `OVERLAPPED` without an event or APC routine (and without `FILE_SKIP_COMPLETION_PORT_ON_SUCCESS`), `complete_now()` only fills `Internal`/`InternalHigh` and posts no IOCP packet, leaving a caller waiting on `GetQueuedCompletionStatus` hung indefinitely. (The new tests in `ws2_offline_test.cpp:601-635` exercise event and APC only.) 2. **Non-overlapped sockets receive completions they must ignore (`ws2_offline.cpp:851-874`, `903-931`):** `complete_now()` unconditionally writes `*overlapped` and signals `hEvent` or queues an APC whenever `overlapped != nullptr`, without checking whether `s` was created with `WSA_FLAG_OVERLAPPED`. Per the Winsock `WSAIoctl` contract, both `lpOverlapped` and `lpCompletionRoutine` are ignored on non-overlapped sockets. 3. **Minor (`ws2_offline.cpp:264-272`, `612-668`, `858-870`):** - Substituting loopback literals for `"localhost"` does not check `AI_NUMERICHOST` first, so `getaddrinfo("localhost", ..., AI_NUMERICHOST)` can succeed instead of returning `EAI_NONAME`. - In `complete_now()`, heap-allocating `Call` for `QueueUserAPC` leaks if the calling thread exits before entering an alertable wait. AI-assisted review + local MSVC verification.
Tyrannys commented 2026-11-28 02:07:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T02:07:40Z.


@timbot103 thanks, all four points were right. Fixed in 37163d100.

1 and 2 (completion port, non-overlapped sockets): complete_now is gone. The shim no longer completes the caller's overlapped itself. The host's WSAIoctl gets the caller's lpOverlapped and lpCompletionRoutine again, so the completion is reported exactly as Winsock reports it for that socket: a port packet, the event, the routine, or nothing for a socket without WSA_FLAG_OVERLAPPED.

The original problem was the stack frame, and that is fixed in wrap_extension_lookup:

  • The host writes its own pointer and byte count into a small heap block of the shim's, not into &real_ext on the stack and not into the caller's buffer.
  • The block is freed when the call completes (the normal case). It is kept if the host ever reports WSA_IO_PENDING, since the host may still write to it then.
  • The wrapper is written into the caller's buffer before the host is called, so a packet another thread dequeues already finds the wrapped ConnectEx/WSASendMsg, never the native one.
  • On failure the buffer gets its old contents back.

3a (AI_NUMERICHOST): localhost is passed on unchanged under AI_NUMERICHOST, so the host refuses it with EAI_NONAME and does no lookup.

3b (the APC record leak): gone with complete_now.

Evidence. What Windows 11 itself does for this lookup with an overlapped (a standalone probe on an overlapped socket):

  • event: set;
  • routine: run once at the next alertable wait;
  • completion port: one packet;
  • in each case rc == 0, lpcbBytesReturned == 8, and Internal/InternalHigh 0.

ws2_offline_test now checks:

  • a completion-port socket with an OVERLAPPED without event or routine: GetQueuedCompletionStatus returns the packet (our key, our OVERLAPPED), and the buffer holds the wrapped ConnectEx;
  • a socket without WSA_FLAG_OVERLAPPED: the event and OVERLAPPED end the same as after the host's own WSAIoctl on the same socket;
  • getaddrinfo("localhost", AI_NUMERICHOST) is EAI_NONAME, and "127.0.0.1" is still answered.

The event and routine checks now expect what Windows does (no byte count in the OVERLAPPED).

With the previous commit's shim these 3 new checks fail. With this one, 87/87 pass. Windows 11, MSVC (VS 18), RelWithDebInfo.

AI-assisted (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232149338 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7232149338). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T02:07:40Z. --- @timbot103 thanks, all four points were right. Fixed in 37163d100. 1 and 2 (completion port, non-overlapped sockets): `complete_now` is gone. The shim no longer completes the caller's overlapped itself. The host's `WSAIoctl` gets the caller's `lpOverlapped` and `lpCompletionRoutine` again, so the completion is reported exactly as Winsock reports it for that socket: a port packet, the event, the routine, or nothing for a socket without `WSA_FLAG_OVERLAPPED`. The original problem was the stack frame, and that is fixed in `wrap_extension_lookup`: - The host writes its own pointer and byte count into a small heap block of the shim's, not into `&real_ext` on the stack and not into the caller's buffer. - The block is freed when the call completes (the normal case). It is kept if the host ever reports `WSA_IO_PENDING`, since the host may still write to it then. - The wrapper is written into the caller's buffer *before* the host is called, so a packet another thread dequeues already finds the wrapped `ConnectEx`/`WSASendMsg`, never the native one. - On failure the buffer gets its old contents back. 3a (`AI_NUMERICHOST`): `localhost` is passed on unchanged under `AI_NUMERICHOST`, so the host refuses it with `EAI_NONAME` and does no lookup. 3b (the APC record leak): gone with `complete_now`. Evidence. What Windows 11 itself does for this lookup with an overlapped (a standalone probe on an overlapped socket): - event: set; - routine: run once at the next alertable wait; - completion port: one packet; - in each case `rc == 0`, `lpcbBytesReturned == 8`, and `Internal`/`InternalHigh` 0. `ws2_offline_test` now checks: - a completion-port socket with an OVERLAPPED without event or routine: `GetQueuedCompletionStatus` returns the packet (our key, our OVERLAPPED), and the buffer holds the wrapped `ConnectEx`; - a socket without `WSA_FLAG_OVERLAPPED`: the event and OVERLAPPED end the same as after the host's own `WSAIoctl` on the same socket; - `getaddrinfo("localhost", AI_NUMERICHOST)` is `EAI_NONAME`, and `"127.0.0.1"` is still answered. The event and routine checks now expect what Windows does (no byte count in the OVERLAPPED). With the previous commit's shim these 3 new checks fail. With this one, 87/87 pass. Windows 11, MSVC (VS 18), RelWithDebInfo. AI-assisted (Claude Code)
zmasi commented 2026-11-28 06:38:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T06:38:38Z.


#2533 | head 37163d100f (merged cleanly with main 6dfca64280) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^ws2_offline$" --output-on-failure | red on main: ws2_offline_test fails and crashes with 0xC0000005 (STATUS_ACCESS_VIOLATION) after gethostbyname(NULL) / "" was allowed through is_loopback_node_a instead of being refused with WSAHOST_NOT_FOUND | green on PR+main: 1/1 CTest passes (ws2_offline 87/87 checks in 1.08s, verifying empty/null local-host name refusal, localhost -> 127.0.0.1/::1 literal rewrite, AI_NUMERICHOST preservation, and overlapped/IOCP/completion-routine/non-overlapped WSAIoctl extension-pointer wrapping); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235427379 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7235427379). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T06:38:38Z. --- #2533 | head 37163d100f429ba5467f104142268b575c8d49a1 (merged cleanly with main 6dfca642807631bbe41d6925f152529f99c71ce2) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^ws2_offline$" --output-on-failure` | red on main: `ws2_offline_test` fails and crashes with `0xC0000005` (`STATUS_ACCESS_VIOLATION`) after `gethostbyname(NULL)` / `""` was allowed through `is_loopback_node_a` instead of being refused with `WSAHOST_NOT_FOUND` | green on PR+main: `1/1` CTest passes (`ws2_offline` `87/87` checks in `1.08s`, verifying empty/null local-host name refusal, `localhost` -> `127.0.0.1`/`::1` literal rewrite, `AI_NUMERICHOST` preservation, and overlapped/IOCP/completion-routine/non-overlapped `WSAIoctl` extension-pointer wrapping); `check_no_game_data.py` `0` violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes
timbot103 commented 2026-11-28 14:36:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T14:36:13Z.

Review: COMMENTED


Static code audit against 37163d100 and ec740bcc3. I would request changes for four issues.

  • runtime/shims/ws2_offline.cpp:879 adds a direct WSAGetLastError import. The standalone test links ws2_32, but the runtime without the optional Rust decoders has no such link dependency. Resolve it through the existing host lookup before calling the provider.
  • runtime/shims/ws2_offline.cpp:270 and :274 drop ::1 for AF_UNSPEC and null hints. A client cannot discover an IPv6-only localhost listener through these calls. Preserve both loopback families under those hints with native result ownership.
  • runtime/shims/ws2_offline.cpp:876 writes the wrapper before the provider reads in_buf. With shared input and output storage that overwrites the GUID. Pass the saved GUID through storage that survives the provider's use.
  • runtime/shims/ws2_offline.cpp:885 leaks the native scratch allocation on every WSA_IO_PENDING return, even after completion or cancellation. Give the storage a completion lifetime or guarantee synchronous lookup while preserving native notification behavior.

The reported Windows tests cover event, IOCP, APC and non-overlapped cases. Please add coverage for overlapping buffers, a forced pending result, both loopback families with default hints, and the Ex variants.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6098417527 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#pullrequestreview-6098417527). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T14:36:13Z. **Review:** COMMENTED --- Static code audit against `37163d100` and `ec740bcc3`. I would request changes for four issues. - `runtime/shims/ws2_offline.cpp:879` adds a direct `WSAGetLastError` import. The standalone test links `ws2_32`, but the runtime without the optional Rust decoders has no such link dependency. Resolve it through the existing host lookup before calling the provider. - `runtime/shims/ws2_offline.cpp:270` and `:274` drop `::1` for `AF_UNSPEC` and null hints. A client cannot discover an IPv6-only localhost listener through these calls. Preserve both loopback families under those hints with native result ownership. - `runtime/shims/ws2_offline.cpp:876` writes the wrapper before the provider reads `in_buf`. With shared input and output storage that overwrites the GUID. Pass the saved GUID through storage that survives the provider's use. - `runtime/shims/ws2_offline.cpp:885` leaks the native scratch allocation on every `WSA_IO_PENDING` return, even after completion or cancellation. Give the storage a completion lifetime or guarantee synchronous lookup while preserving native notification behavior. The reported Windows tests cover event, IOCP, APC and non-overlapped cases. Please add coverage for overlapping buffers, a forced pending result, both loopback families with default hints, and the Ex variants. AI-assisted.
lixonik commented 2026-11-28 20:10:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T20:10:29Z.

Review: COMMENTED


Reviewed and locally tested 37163d100 (runtime/shims/ws2_offline.cpp, runtime/test/ws2_offline_test.cpp).

Local verification:

  • Built ws2_offline_test (MSVC Release / Ninja) and ran ctest -R ^ws2_offline$: 1/1 passed.
  • python -I scripts/check_no_game_data.py: passed.

Holding off on approval because code inspection confirms the remaining issues in runtime/shims/ws2_offline.cpp:

  1. wrap_extension_lookup (runtime/shims/ws2_offline.cpp:879) calls WSAGetLastError() directly instead of resolving it dynamically through host_proc (unlike set_wsa_error and the other host ws2_32.dll calls), introducing a direct import-library dependency on ws2_32.
  2. wrap_extension_lookup (runtime/shims/ws2_offline.cpp:876) overwrites out_buf with &wrapped before invoking real_fn(..., in_buf, ...). If a caller aliases in_buf == out_buf, the requested extension GUID is clobbered before Winsock reads it.
  3. On WSA_IO_PENDING (runtime/shims/ws2_offline.cpp:885), the heap-allocated HostAnswer is never freed.
  4. For AF_UNSPEC, rewriting "localhost" to "127.0.0.1" drops ::1 loopback results.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6099900951 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#pullrequestreview-6099900951). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T20:10:29Z. **Review:** COMMENTED --- Reviewed and locally tested `37163d100` (`runtime/shims/ws2_offline.cpp`, `runtime/test/ws2_offline_test.cpp`). Local verification: - Built `ws2_offline_test` (MSVC Release / Ninja) and ran `ctest -R ^ws2_offline$`: 1/1 passed. - `python -I scripts/check_no_game_data.py`: passed. Holding off on approval because code inspection confirms the remaining issues in `runtime/shims/ws2_offline.cpp`: 1. `wrap_extension_lookup` (`runtime/shims/ws2_offline.cpp:879`) calls `WSAGetLastError()` directly instead of resolving it dynamically through `host_proc` (unlike `set_wsa_error` and the other host `ws2_32.dll` calls), introducing a direct import-library dependency on `ws2_32`. 2. `wrap_extension_lookup` (`runtime/shims/ws2_offline.cpp:876`) overwrites `out_buf` with `&wrapped` before invoking `real_fn(..., in_buf, ...)`. If a caller aliases `in_buf == out_buf`, the requested extension GUID is clobbered before Winsock reads it. 3. On `WSA_IO_PENDING` (`runtime/shims/ws2_offline.cpp:885`), the heap-allocated `HostAnswer` is never freed. 4. For `AF_UNSPEC`, rewriting `"localhost"` to `"127.0.0.1"` drops `::1` loopback results. AI-assisted (Antigravity, Gemini).
OreoFR commented 2026-11-28 22:04:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:04:17Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 37163d100
  • Test: ctest -R "^ws2_offline$" + gta6rt build
  • Red on main: crash (SegFault, "geth" failure)
  • Green with the PR: ws2_offline OK, but gta6rt.exe does not link: LNK2019 __imp_WSAGetLastError in ws2_offline.cpp (wrap_extension_lookup); gta6rt does not link ws2_32; reproduced on main + this PR alone
  • Verdict: FAILS (only ws2_offline_test links ws2_32; needs another call than WSAGetLastError, or ws2_32 linked into gta6rt)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246475089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7246475089). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:04:17Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `37163d100` - Test: `ctest -R "^ws2_offline$" + gta6rt build` - Red on main: crash (SegFault, "geth" failure) - Green with the PR: ws2_offline OK, but gta6rt.exe does not link: LNK2019 __imp_WSAGetLastError in ws2_offline.cpp (wrap_extension_lookup); gta6rt does not link ws2_32; reproduced on main + this PR alone - Verdict: FAILS (only ws2_offline_test links ws2_32; needs another call than WSAGetLastError, or ws2_32 linked into gta6rt) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
TheGeogeo commented 2026-11-28 23:23:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:23:13Z.


Correction: I missed a link failure in this review. With this change, gta6rt.exe calls WSAGetLastError directly in rt::ws2::wrap_extension_lookup (runtime/shims/ws2_offline.cpp:879), while the rest of the shim reaches it through host_proc. gta6rt does not link ws2_32, so the link fails with LNK2019 __imp_WSAGetLastError, then LNK1120.

My build did not catch it: in my configuration the Rust XMA2/Opus decoders' interface libraries bring ws2_32 into the gta6rt link. I reproduced it here by linking gta6rt.exe without ws2_32.lib. That adds exactly one unresolved symbol over main: __imp_WSAGetLastError, referenced in wrap_extension_lookup. A fix through host_proc (no ws2_32) is being prepared by another tester.

Original comment below.


Tested 37163d100 merged (no commit) with main aa918e5d9. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), RelWithDebInfo, Ninja.

  • Green: ws2_offline passes.
  • Red: with runtime/shims/ws2_offline.cpp back to main, ws2_offline prints FAIL geth (the output stops there) and then crashes: ctest reports SEGFAULT.
  • No regression: the merge relinks 9 executables, and their 20 other tests pass.

No blocker from my side. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247395878 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7247395878). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T23:23:13Z. --- **Correction:** I missed a link failure in this review. With this change, `gta6rt.exe` calls `WSAGetLastError` directly in `rt::ws2::wrap_extension_lookup` (`runtime/shims/ws2_offline.cpp:879`), while the rest of the shim reaches it through `host_proc`. `gta6rt` does not link `ws2_32`, so the link fails with `LNK2019 __imp_WSAGetLastError`, then `LNK1120`. My build did not catch it: in my configuration the Rust XMA2/Opus decoders' interface libraries bring `ws2_32` into the `gta6rt` link. I reproduced it here by linking `gta6rt.exe` without `ws2_32.lib`. That adds exactly one unresolved symbol over `main`: `__imp_WSAGetLastError`, referenced in `wrap_extension_lookup`. A fix through `host_proc` (no `ws2_32`) is being prepared by another tester. Original comment below. --- Tested `37163d100` merged (no commit) with `main` `aa918e5d9`. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), RelWithDebInfo, Ninja. - Green: `ws2_offline` passes. - Red: with `runtime/shims/ws2_offline.cpp` back to `main`, `ws2_offline` prints `FAIL geth` (the output stops there) and then crashes: ctest reports `SEGFAULT`. - No regression: the merge relinks 9 executables, and their 20 other tests pass. No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-28 23:25:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T23:25:03Z.


Merged after TheGeogeo's red/green check (check: green with this PR, red with main's code, no regression over the relinked tests) and a re-check here: no conflict with main 1c97c43fd, same head as checked, no-game-data green, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on main or Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ). The Python jobs fail on main too.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247416312 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7247416312). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T23:25:03Z. --- Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7247395878): green with this PR, red with `main`'s code, no regression over the relinked tests) and a re-check here: no conflict with `main` 1c97c43fd, same head as checked, `no-game-data` green, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on `main` or Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ). The Python jobs fail on `main` too. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
MoonEyes commented 2026-11-28 23:38:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T23:38:25Z.


Heads-up after merge: this breaks the gta6rt.exe link on Windows/MSVC builds without the Rust XMA decoder (LNK2019 __imp_WSAGetLastError, then LNK1120, reported by OreoFR on main a9e247cd6). ws2_offline.cpp:36 resolves every host ws2_32 call dynamically so gta6rt needs no ws2_32.lib; the new direct WSAGetLastError() call does not, and CI only linked because the XMA decoder target brings ws2_32 (runtime/CMakeLists.txt:155). A fix through the existing host_proc<LastErrFn>("WSAGetLastError") (ws2_offline.cpp:388) is being prepared by OreoFR's agent. Until it lands, rebuild runtime/ from 1bc055e6c. My merge, my miss.

AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247565245 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2533#issuecomment-7247565245). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T23:38:25Z. --- Heads-up after merge: this breaks the `gta6rt.exe` link on Windows/MSVC builds without the Rust XMA decoder (`LNK2019 __imp_WSAGetLastError`, then `LNK1120`, reported by OreoFR on `main` a9e247cd6). `ws2_offline.cpp:36` resolves every host ws2_32 call dynamically so gta6rt needs no `ws2_32.lib`; the new direct `WSAGetLastError()` call does not, and CI only linked because the XMA decoder target brings `ws2_32` (`runtime/CMakeLists.txt:155`). A fix through the existing `host_proc<LastErrFn>("WSAGetLastError")` (`ws2_offline.cpp:388`) is being prepared by OreoFR's agent. Until it lands, rebuild `runtime/` from `1bc055e6c`. My merge, my miss. AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2533
No description provided.