{"UUID":"db126e26-be84-4286-a778-975bbe87df0d","URL":"https://community.eveonline.com/news/dev-blogs/sleeping-beauty/","ArchiveURL":"","Title":"EVE Online Stackless Python tasklet memory reuse bug","StartTime":"0001-01-01T00:00:00Z","EndTime":"0001-01-01T00:00:00Z","Categories":["cloud"],"Keywords":["eve online","bug","stackless python","tasklets","memory reuse","ui","drone window","ccp games"],"Company":"CCP Games","Product":"EVE Online","SourcePublishedAt":"2017-02-15T15:40:00Z","SourceFetchedAt":"2026-05-04T17:54:08.121845Z","Summary":"Documents a Stackless Python memory reuse bug that took years to track down.","Description":"CCP karkur initiated an investigation into an issue where the drone window in EVE Online would occasionally stop updating. Her initial debugging revealed that tasklets were failing to wake up from sleep, entering an unscheduled and unblocked state. A reproduction script was developed to reliably trigger this \"sleeping disorder\" in tasklets.\n\nThe problem was traced to a subtle memory reuse bug within the game's Stackless Python implementation, specifically concerning channel objects used by sleeping tasklets. When a tasklet was killed, its associated channel object's memory was immediately freed. If another tasklet then went to sleep on the same processing tick, it could inadvertently be assigned the same memory address for its new channel.\n\nThis premature memory reuse led to a critical flaw: when the system attempted to clean up the *originally killed* tasklet, it would mistakenly identify and remove the *new* tasklet's channel from the sleeper heap. This left the new tasklet in a permanent \"limbo\" state, unable to be scheduled or woken up.\n\nThe customer impact included various UI elements, such as the drone window, overview, and health bars, failing to update. These issues were difficult to reproduce but were reported by players, particularly after large-scale events like mass tests or heavy combat, indicating a degraded gameplay experience.\n\nThe resolution involved a targeted code change: moving the Py_DECREF calls for channel objects into the SleepWallclock function. This ensures that channel objects are not prematurely recycled, thereby preventing the memory address collision and the subsequent erroneous removal of active tasklets from the sleeper queue."}