LockerGnomeTech news and nostalgia for today's technology professionals
Subscribe

Search

Software

Windows 95 Crashed an MS-DOS Game by Granting a 65th Memory Handle

A classic compatibility bug report shows why lifting an old memory limit triggered a buffer overflow in software that secretly relied on being told no.

A retro woodblock-and-pixel editorial illustration showing Chris Pirillo standing beside a towering 1990s desktop memory rack packed with sixty-four glowing blocks, looking exasperated as a sixty-fifth block spills off the end and knocks a neighboring circuit tray into disarray against a quiet slate-blue grid background.
Illustration: LockerGnome

A bug report landed on Microsoft’s desk with reproduction steps that looked like a cheat code for a haunted cartridge. “Start the game, then go to City 1, then City A, then City Alpha, then City 𓀀, then City ⛄. When you go to City ⛄, the game crashes,” Raymond Chen wrote, substituting placeholder names for the real in-game destinations. “I gotta say: Our testers were quite thorough.”

The game ran fine for quite a while before keeling over, which made the fifth-city death look random at first glance. Every time the player traveled to a new city, the program requested another chunk of Expanded Memory Manager (EMM) memory. Under normal MS-DOS conditions, it would eventually hit the ceiling and presumably start swapping data out to disk.

Windows 95 ruined that peaceful arrangement by being generous. When the player moved to the fifth city, the game made its 65th request for an EMM memory handle, and Windows 95 granted it — “because Windows 95 tries to be all awesome like that,” as Chen put it. Turns out Windows 95 gave the game more than it could handle, literally by one.

Inside the game’s code, every allocated handle went into a fixed-size table with room for exactly 64 entries. That never caused trouble on MS-DOS because the EMM386 driver defaulted to 64 EMM handles. On the 65th request, DOS simply handed back the error “no more EMM handles available,” and the game moved on without touching slot 65. The developer had effectively outsourced array bounds checking to an operating system default (bounds checks cost extra, apparently).

Once Windows 95 said yes, the game dutifully wrote that 65th handle right past the end of its 64-slot array. That buffer overflow would have been bad enough on its own, yet memory layout roulette made it fatal. The variable sitting immediately after the array held the location of the EMM page frame. Corrupted by the stray handle, the game started copying memory into and out of random addresses, scrambling its own state until it crashed spectacularly.

Chen summed up the engineering lesson without ceremony: “Of course, once you know what the problem is, the fix is simple: Limit the program to at most 64 EMM handles.” He left the game’s real title unnamed, preserving the mystery of which fifth city finally broke the camel’s back.

Every infrastructure upgrade carries a quiet version of this exact trap. Platform teams love announcing bigger ceilings — more handles, larger buffers, higher concurrency limits — as pure upside (and marketing loves putting those bigger numbers on a slide). Somewhere downstream, though, a piece of production code written under the old cap may be using that exact failure threshold as its undocumented safety rail.

When a program only survives because the layer underneath keeps telling it no, turning the platform into a yes-man turns a clean error into silent corruption. That is why compatibility engineering stays weirdly humble decades after Windows 95. Shipping a wider pipe is the easy part; keeping older software from drowning in it requires knowing exactly where to pinch the hose back down.

Sometimes the kindest API answer is no.

More Software

Every Software story →