Welcome to MSDN Blogs Sign in | Join | Help

What is the window nesting limit?

In the old days, Windows didn't bother enforcing a nesting limit because, well, if you want to nest windows 200 deep, that's your decision. Many window operations are recursive, but since everything happened on the application's stack, it was your own responsibility to make your stack big enough so it didn't overflow.

But Windows NT moved the window manager off the application stack (first into a separate process, then into kernel mode). So now the OS needs to watch out for stack overflow attacks from people creating too many nested windows.

The window nesting limit was set to 100 for the early days of Windows NT. For Windows XP, it dropped to 50 because increased stack usage in some internal functions caused us to overflow at around 75. Dropping to 50 created some breathing room.

Disclaimer: I was not personally involved in this issue. I'm just reporting what I was able to figure out from reading checkin logs.

Published Thursday, December 18, 2003 7:00 AM by oldnewthing
Filed under:

Comments

# re: What is the window nesting limit?

Thursday, December 18, 2003 8:21 AM by Ian Hanschen
I wish *some* checkin logs(e.g. wmgr) were public, would make an interesting read.

# re: What is the window nesting limit?

Thursday, December 18, 2003 8:27 AM by joe
Check in to where? Are you using SourceSafe?

# How many application broke when you made this change?

Thursday, December 18, 2003 8:43 AM by Ian Ringrose.
I have only know of one, did other people hit this problem?

ianr at bigfoot dot com

# re: What is the window nesting limit?

Thursday, December 18, 2003 9:15 AM by Jeroen-bart Engelen
AFAIK Microsoft doesn't use SourceSafe for OS development. They have their own special software.

# re: What is the window nesting limit?

Thursday, December 18, 2003 10:00 AM by (6)
Last I heard Microsoft used a Perforce derivative. I suppose the problem with publishing some checkin notes is it provides information about the Windows internals which Microsoft may not wish to divulge (particularly mid-development when anything can change, or be dropped)

# re: What is the window nesting limit?

Thursday, December 18, 2003 10:23 AM by asdf
I can't imagine any apps needing more than 10 nested windows (and I'm being generous there). Ian, what kind of app ran into this problem so I can stay far, far away from that company?

# re: What is the window nesting limit?

Thursday, December 18, 2003 11:49 AM by Ian Hanschen
No idea, asf.

# re: What is the window nesting limit?

Thursday, December 18, 2003 12:17 PM by Mike Dimmick
You can find some (limited) information about MS' source control system (SourceDepot) in a talk that Mark Lucovsky gave at Usenix's 4th Windows Systems Symposium. You can find the slides at http://www.usenix.org/events/usenix-win2000/invitedtalks/lucovsky.ppt.

Apparently some teams do use SourceSafe, but the OS team is not one of them.

# re: What is the window nesting limit?

Friday, December 19, 2003 8:29 AM by Ian Hanschen
Raymond,
As a test(I'm interested in oditties concerning the window manager, it's an obsession..) I wrote an app to test the recursion limit. When creating the 48th window, the cardinal checking for DCBAABCD in callwindowproc from keusermodecallback failed. I would guess the top parent could be considered a child of the desktop itself, but the stack is still being eaten before 50 windows are hit(and it seems to be the temp stack put together by keusermodecallback). That's with the uxtheme hooks enabled though, so it's possible that the extra stack overhead there is the cause.

# re: What is the window nesting limit?

Saturday, December 20, 2003 3:14 PM by Jordan Russell
Windows 2000 (SP4) also appears to have a limit of 50.
New Comments to this post are disabled
 
Page view tracker