Files
sentry[bot] 643c692784 Fix: Universal access port TOCTOU race and disconnect issues (#22554)
* Please describe the intent of your changes in a clear fashion.
This PR addresses two related bugs concerning the universal access port
and cable:

**1. TOCTOU Race Condition Leading to Crash (SERVER-PROD-X9)**
* **Root Cause:** When inserting a universal access cable into an IPC's
access port, a check for `access_port.internal_port` occupancy occurs
before a `do_mob` delay (which can include a consent dialog and a
2-second wait). If another action or player inserts something into the
port during this delay, the subsequent call to `insert_item()` would
find `internal_port` already occupied and trigger a `crash_with()`,
leading to a server crash.
*   **Fix:**
* A re-check for `access_port.internal_port` occupancy and the continued
existence of the `access_port` itself has been added immediately after
the `do_mob` delay in `access_cable/attack()`. If the port is now
occupied or no longer exists, the insertion attempt is gracefully
aborted with a user message.
* The `crash_with()` call in `insert_item()` has been replaced with a
`log_debug()` and an early return, ensuring that any future unexpected
state in `internal_port` leads to graceful degradation rather than a
server crash.

**2. Stale `internal_port` on Cable Disconnect**
* **Root Cause:** The `access_port` did not override the generic
`remove_cable()` proc. When a cable was retracted or removed,
`access_port.internal_port` was not explicitly cleared, causing the port
to appear permanently occupied even after the cable was gone.
*   **Fix:**
* An override for `remove_cable()` has been added to
`/obj/item/organ/internal/machine/access_port`. This ensures that
`clear_port()` is called, properly nulling `internal_port` when the
cable is removed.

* Please make sure that, in the case of mapping changes, you include
images of these changes in the PR's description.
* Please make sure to mark your PR as wip or review required by making a
comment with !wip or !review required
* If you include sprites/sounds/... (assets) that you have not created
yourself specify the license and original author below.
* Ensure that you also credit them in the appropriate location /
changelog as specified in the contributor guidelines

### Asset Licenses
The following assets that **have not** been created by myself are
included in this PR:

| Path | Original Author | License |
| --- | --- | --- |
| icons/example.dmi | ExamplePerson (Example Station) | CC0 |

Fixes SERVER-PROD-X9

---------

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2026-06-01 10:33:15 +00:00
..