LockerGnomeTech news and nostalgia for today's technology professionals
Subscribe

Search

GamingNintendoretro

Windows gave SimCity a special memory mode because the game read memory it had freed

Joel Spolsky’s developer account captures the awkward promise behind operating-system upgrades: a customer expects a familiar game to keep running, bug and all.

Chris kneels beside a tiny model city and props up a building that would fall into a gap in the ground
Illustration: LockerGnome

SimCity kept using memory after giving it back, and Windows got the job of making that mistake keep working. The city had a use-after-free problem. Eviction, apparently, was negotiable.

Joel Spolsky recounts the incident in his June 13, 2004 essay about Microsoft’s application platform. He says he heard it from one of SimCity’s developers. That attribution matters: this is his reported conversation, with an unnamed developer, rather than a published patch or a line-by-line reconstruction of the Windows change.

According to the account, the game used memory immediately after freeing it. That happened to work under DOS. Under Windows, another application could take the released memory promptly, and SimCity crashed during compatibility testing. A program returning something and reaching for it again creates a timing problem that the old environment can accidentally conceal.

Windows testers reported the failure. The developers then disassembled the game, stepped through it in a debugger and found the invalid access. Spolsky says they added a check for SimCity and made the allocator behave specially when it was running. The change preserved the game by accommodating the very behavior a programmer should remove.

Spolsky calls the original access “a major no-no.” That is the point to keep attached when retelling this. Successful compatibility work does not make released memory safe to use. It makes a particular broken application survive a particular change in its surroundings, with the operating-system team carrying the exception.

The customer sees a game that worked yesterday. The engineer sees an application violating a rule. Both descriptions can be true, and neither reimburses the customer for the software that just stopped working. The Windows team absorbed that disagreement into the platform, where the workaround could travel with the upgrade.

Spolsky puts the story inside a larger argument about why application libraries matter to operating systems. People buy the ability to run useful programs. A technically tidier operating system that abandons the program they want creates a very untidy purchasing decision. The compatibility team gets to debug that decision too (lucky them).

The account leaves important engineering details open. Spolsky supplies no allocator implementation, exact Windows version or measurable cost of the exception. A modern rewrite of the story cannot fill those gaps simply because Windows 95 is the version people most readily associate with heroic compatibility work.

Testers found a crashing game, engineers traced the bad access, and the operating system learned to recognize the offender. SimCity had already returned the memory. Windows let the mayor back in.

Orange links with a double underline go to Amazon. As an Amazon Associate, LockerGnome earns from qualifying purchases.

More Gaming

Every Gaming story →