Skip to content
TopicTracker
From devblogs.microsoft.com/oldnewthingView original
TranslationTranslation

Windows stack limit checking retrospective, follow-up

The post discusses the reasoning behind choosing which register to use when passing the desired stack allocation size for stack limit checking in Windows.

Background

- "The Old New Thing" is Raymond Chen's long-running blog (Microsoft, since 2003) that dives into Windows internals, historical design decisions, and quirks of the OS/compiler stack. - This post is part of a series on how Windows checks for stack overflow. The key question: which CPU register did the OS use to tell the kernel how much stack space a thread needed? - On x86, the `EAX` register was chosen because it's a caller-saved register (free to clobber) and was already used for return values — so using it didn't force extra save/restore code. This mattered in the 1990s when every CPU cycle counted. - The series explores low-level OS/compiler coordination that most developers never think about, but that underpins why Windows handles stack limits the way it does today.

Related stories

  • Cancellation of Windows Runtime activities is inherently asynchronous, meaning that after requesting cancellation, the operation may not terminate immediately. This requires developers to properly handle the asynchronous nature of cancellation in their code.

  • The article compares three approaches to serving files over HTTP in Linux: synchronous blocking I/O, epoll-based asynchronous I/O, and io_uring. It benchmarks each method using a simple file server, showing that io_uring offers the highest throughput and lowest latency, especially under high concurrency.

  • PHP typically sends HTTP headers only when a script finishes, causing delays for redirects after long operations. The article notes this issue and mentions that complex workarounds exist for sending headers before script completion.