Commit Graph
31 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 1dea9d6b37 AdhocMatching: Hold peerlock while HLE calls walk the peer list
SelectTarget, CancelTarget, AbortSendData, GetMembers and
__NetMatchingCallbacks looked up peers and changed their state unlocked,
while the input thread can free them (DEATH, BYE, CANCEL, timeouts).
GetMembers locked only the context lookup. SelectTarget and CancelTarget
queue input messages, which became safe under peerlock with the previous
change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 15:35:55 +02:00
Henrik RydgårdandClaude Opus 5.5 e423776f1a AdhocMatching: Stop a running context before taking peerlock in Delete
Delete held peerlock while Stop joined the matching threads, which take
peerlock in their loops and while sending BYE, so deleting a running
context could hang (sceNetAdhocMatchingTerm and emulator shutdown go
through here).

Since the context is now still linked while its threads wind down, they
send BYE and clear the peer list as on an explicit Stop, instead of
skipping that when it was the only context.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 15:35:47 +02:00
Henrik RydgårdandClaude Opus 5.5 f617d6f569 AdhocMatching: Don't hold the message stack locks while handling messages
The input thread held inputlock while sending, and the send functions take
peerlock, the reverse of the emulator thread's peerlock -> inputlock (via
send*Message). The event thread held eventlock while queueing callbacks,
which takes adhocEvtMtx, closing a cycle with the input thread
(peerlock -> eventlock in spawnLocalEvent) and __NetMatchingCallbacks
(adhocEvtMtx -> peerlock).

Detach messages under the lock and handle them after unlocking. The order
is unchanged: the event thread still pops one message at a time, and the
input thread still sends the whole stack as a batch, with anything linked
meanwhile left for the next pass (rather than overwritten, as a message
linked from within a send was before). The two copies of the input send
chain become sendInputMessages().

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 15:35:47 +02:00
Henrik RydgårdandClaude Opus 5.5 2a54eff606 AdhocMatching: Don't write past the GetMembers buffer
The sibling/child loop didn't check requestedpeers, so a game passing a
buffer smaller than the member count got it overflowed. Also validate the
guest range before writing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 15:31:55 +02:00
Acts1631 6fdd700b4c Bound matching BIRTH peer additions
An established parent could send repeated BIRTH packets that added
duplicate siblings beyond the matching context peer limit. The growing
list consumed memory and made peer lookups increasingly costly.

Serialize peer-list validation and insertion, ignore existing members,
and enforce maxpeers before allocating a sibling.
2026-10-09 15:31:55 +02:00
Acts1631 7de6a6ccfb Avoid overflow in matching packet length checks
Matching packet handlers added untrusted payload lengths to fixed header
sizes before comparing them with the datagram length. Large values could
overflow and permit out-of-bounds reads. Compare against the remaining
packet size instead, and reject negative ACCEPT sibling counts.
2026-10-03 21:55:32 -04:00
Henrik RydgårdandClaude Opus 5.5 639e57c2bd Savestate: Keep pending adhocctl requests, so a waiting Init survives a load
With WLAN on and no server reachable, sceNetAdhocctlInit keeps its thread
waiting for the login. The load dropped the request, and the wait ended in
BUSY, which Init can't retry. Splinter Cell then ran its failure path with
a deleted event flag. Also stop freeing matching event buffers into the
restored allocator, and take the event lock when clearing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 09:34:06 -06:00
Henrik Rydgård c5e4d0d90d Rename the get-memory-pointer functions to make it clear where CPU exceptions can happen. 2026-08-12 14:06:16 +02:00
Henrik Rydgård 3bd41376da More memory cleanup 2026-08-11 20:12:10 +02:00
Henrik Rydgård 8cb1732564 Clean up the memory partition ID enum 2026-07-25 14:53:02 +02:00
Henrik Rydgård 040996f185 Use new/delete properly for SceNetAdhocMatchingContext. It contains non-POD C++ objects. 2026-07-23 11:17:44 +02:00
Henrik Rydgård 702e18bd2d Fix typo (thanks Nemo)
See #d0dd10c
2026-07-18 23:55:25 +02:00
Henrik Rydgård d0dd10ce6b Avoid memsetting a non-POD struct (fixes compiler warning) 2026-06-16 11:05:16 +02:00
Katharine Chui f218138f2e add missing null check during actOnDeathPacket
It is not impossible for deadkid to not be tracked, so we have to
null check that
2026-02-26 13:18:03 +01:00
Henrik Rydgård 3e2dce1e54 Move AdHoc error codes to the big enum, fix the naming convention to be consistent 2025-08-06 17:44:54 +02:00
Nemoumbra c7aafd4cbe Deduplicated a config variable 2025-07-02 01:30:21 +03:00
Nemoumbra 921fd32969 8 vars moved to NetAdhocCommon, 1 var moved to sceNetAdhocMatching 2025-07-01 19:56:09 +03:00
Henrik Rydgård 4e25f44eef Rename some module-related functions to include HLE where appropriate 2025-03-31 11:17:50 +02:00
Henrik Rydgård 0f840e6240 Move JPEG error codes to the big enum, some include cleanup 2025-03-21 20:44:46 +01:00
Henrik Rydgård e24317b20b A lot more logging fixes 2025-01-20 12:20:21 +01:00
Henrik Rydgård 7d2ad6980e Another batch of changes 2025-01-20 12:20:21 +01:00
Nemoumbra aae7b187d5 Hadouken fixes: SendData funcs + sceNetAdhocMatchingGetPoolStat 2025-01-05 01:07:10 +03:00
Nemoumbra 94f4ad200b Hadooken fixes: sceNetAdhocMatchingSelectTarget, NetAdhocMatching_CancelTargetWithOpt 2025-01-05 00:46:42 +03:00
Nemoumbra 3497ccacb5 Hadooken codestyle fix + cleaned up NetAdhocMatching_Start 2025-01-05 00:08:20 +03:00
Nemoumbra f7289ff22a Simplified 2 more matching funcs 2025-01-04 23:52:31 +03:00
Nemoumbra 4f623db57a Added early returns for actOn{X}Packet funcs 2025-01-04 23:42:39 +03:00
Nemoumbra 110799f09d Cleaned up broadcastHelloMessage and broadcastPingMessage 2025-01-04 21:08:31 +03:00
Nemoumbra 9f94e035a7 Added early returns for send{X}Packet funcs 2025-01-04 20:29:39 +03:00
Nemoumbra 9f4f0a4e6a Brace codestyle fix 2025-01-04 19:55:50 +03:00
Nemoumbra 96f9749e2e Split out the matching code from sceNetAdhoc.cpp 2025-01-03 04:59:26 +03:00
Nemoumbra b265b3b994 Added empty sceNetAdhocMatching files 2025-01-02 16:03:37 +03:00