Skip to content

tests: kvshare_orphan_test picks its port in its driver and holds no route lock (same window, one hop from the census) #1603

Closed as not planned

Description

@bong-water-water-bong

Found while auditing the driver layer for #1485 (the port-pick migration). tests/kvshare_orphan_test.sh picks its port one hop away from the file the census
reads, so it holds no route lock — the same window the migration has been closing for eight batches, in the one shape a .sh-text census cannot see.

Evidence

tests/kvshare_orphan_test.sh:17   "…runs an HRX llama-server in …"
tests/kvshare_orphan_test.sh:34   import kvshare_fd_handoff as k
tests/kvshare_fd_handoff.py:66    def free_port():
tests/kvshare_fd_handoff.py:68        s.bind(("127.0.0.1", 0))
tests/kvshare_fd_handoff.py:69        p = s.getsockname()[1]
tests/kvshare_fd_handoff.py:70        s.close()                    <- pick, release, hand the number to the server it starts
CMakeLists.txt (_onebit_route_tests)                              <- 0 matches for kvshare_orphan_test, at main and at #1602's head

So the test releases a port and starts a server that binds it a moment later — with nothing serialising it against another test doing the same. It is not a
1bit serve front port, so it was correctly out of the migration's scope; but the lock is about any port, which is exactly why hrx_cpu_weight_parity stays
in _onebit_route_tests while starting llama-server itself.

Fix (one line, plus the assertion that keeps it)

list(APPEND _onebit_route_tests hybrid_e2e pm_laya_route hrx_cpu_weight_parity hybrid_kvshare_e2e kvshare_orphan_test)

and, in tests/route_port_lock_test.py, the same conditional assertion #1602 adds for its sibling — if "kvshare_orphan_test" in by_name: assertEqual(lock_of(…), "route_ports", …). The floor stays at 9: found counts scripts matching BIND_RE, and this script's text has no bind in it.

Ordering

#1602 touches the same two files (CMakeLists.txt and tests/route_port_lock_test.py) and is READY at 1decaefe for the sibling case
(hybrid_kvshare_e2e). Either fold this line into #1602 — the audit that found this one is the comment I left there — or land #1602 first and take this as a
one-line follow-up. I have noted it on #1602 and on #1485.

Activity

  1. bong-water-water-bong commented on Nov 9, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Closing this: my own evidence refutes it. I filed it from "two callers of kvshare_fd_handoff.py", and then checked what the second caller actually does with it:

    tests/kvshare_orphan_test.sh:34   import kvshare_fd_handoff as k
    tests/kvshare_orphan_test.sh:35   child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"],
                                           preexec_fn=k.die_with_parent, start_new_session=True)
    

    It imports the driver for die_with_parent only — a preexec_fn helper — and its "child" is python3 -c "time.sleep(120)". No server, no port, and
    free_port() (which is only called from main(), kvshare_fd_handoff.py:112) never runs in that process. So there is no pick-and-release window here and the
    route lock would be held for nothing.

    That means the driver layer has exactly one real port picker — hybrid_kvshare_e2e, fixed by #1602 — and this issue was a miscount on my part. Retracting it
    here, on #1602 (where I suggested the extra line) and on #1485 (where I claimed two members), each with this evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions