Skip to content

fix(w3d): Fix crashes, leaks and memory exhaustion on device reset - #639

Open
tintinhamans wants to merge 10 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/upstream-device-reset
Open

tintinhamans wants to merge 10 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/upstream-device-reset

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 15, 2026 •

Copy link
Copy Markdown

Fixes crashes, leaks and memory exhaustion on device reset (alt-tab, lock screen, UAC, resolution change). Folds #632 and #634. All but two commits are ports of merged upstream fixes, with the upstream number in the title: TheSuperHackers#3449 (refill the tree buffers), TheSuperHackers#3479 (flat terrain tile leak), TheSuperHackers#3440 (copy the shroud manually instead of CopyRects, plus its follow-up), TheSuperHackers#3543 (release the cached textures at shutdown), TheSuperHackers#3045 (texture access bounds in W3DShroud::getShroudLevel()), TheSuperHackers#3475 (release the D3D8 library and interface when DX8Wrapper::Init() fails) and TheSuperHackers#3566 (fill every MissingTexture mip level directly, including the last row). One of the other two commits unbinds device resources before Reset, the same as TheSuperHackers#3450 (approved, not merged yet).

The CopyRects shroud upload made one reset take hundreds of MB on NVIDIA (CLIENT-55X); a 10 minute skirmish lost 316 MB on main, none with this. A bound render target plus a device loss failed Reset forever on an Intel UHD 770 and RTX 4070 Ti, now it recovers.

The other commit falls back to the missing texture when _Create_DX8_Texture (or its cube and volume variants) returns null, e.g. out of video memory after a failed reset. The loader returned success anyway and Lock_Surfaces crashed on the null texture (CLIENT-19P, 3908 crashes, still 14 in the last 30 days).

Tested: z_generals builds, measurements on the upstream build.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/upstream-device-reset branch from cf5f8e9 to 4341f19 Compare October 22, 2026 21:14
@tintinhamans tintinhamans changed the title fix(w3d): Port merged TheSuperHackers device reset fixes fix(w3d): Fix crashes, leaks and memory exhaustion on device reset Oct 22, 2026
@tintinhamans
tintinhamans force-pushed the arctic/go/fix/upstream-device-reset branch from 5dd96f8 to eae7225 Compare October 28, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants