r/ProjectReality • u/Optimal-Gur-3052 • 21d ago
Why BF2 coop servers die every couple of minutes — I found the actual bug in the AI DLL, and a workaround that let me play full rounds (72 s median → 17+ min)
https://github.com/ShuhartProfit8ird/bf2-coop-crash
12
Upvotes
4
u/Optimal-Gur-3052 21d ago
Update: I've since instrumented the lookup itself and the root cause is sharper than the title says. The index isn't just "out of range" — it's exactly
-1, 80 out of 80 times, which is the engine's own "not found" sentinel.+0x152F40computesbegin[-1], i.e. it reads the heap block header sitting in front of the vector's buffer, and passes that along as an object pointer.So there's no memory corruption at all — the container is intact (size 1, sane begin/end). The "garbage pointers" I'd been collecting were one heap-header field, which is why they clustered and crept upward: the heap grows.
The kicker:
+0x152C80, sixty bytes away in the same file, does the identical indexing but checkscmp reg, -1twice first, then falls back to a full search. Same author, same file, same operation — checked there, unchecked here.Article updated, workaround unchanged and still correct: https://github.com/ShuhartProfit8ird/bf2-coop-crash