A free Windows-compatible Operating System - mirrored from GitHub
Find a file
Timo Kreuzer 7de47192fe [PSEH]
Fix a serious bug in PSEH that could lead to stack corruption and was causing CSRSS to crash, when large amounts of text were output on the console.
Background: PSEH used __builtin_alloca to allocate an SEH registration frame on the stack on demand, ie only for the first try level. But there are some nasty things with __builtin_alloca: First it DOES NOT - as one might think - free the allocated memory, once the allocation "goes out of scope", like with local variables, but only on function exit. Therefore it cannot normally be used inside a loop. The trick that PSEH used to "fix" this problem, was to save the stack pointer and reset it back at the end. This is quite problematic, since the rest of the code might assume that the stack pointer is still where it was left off after the allocation. The other thing is that __builtin_alloca() can allocate the memory whenever it likes to. It can allocate everything on function entry or not allocate anything at all, when other stack variables that went out of scope have left enough space to be reused. In csrss it now happened that the allocation was done before the stack pointer was saved, so the memory could not be freed by restoring the old stack pointer value. That lead to slowly eating up the stack since the code was inside a loop.
The allocation is now replaced with a variable sized array. The variable stays in scope until the _SEH2_END and will be automaticall cleaned up by the compiler. This also makes saving and restoring the stack pointer obsolete.
Reliability++

svn path=/trunk/; revision=56442
2012-04-28 20:00:09 +00:00
reactos [PSEH] 2012-04-28 20:00:09 +00:00
rosapps [ROSAPPS] 2012-03-10 13:36:45 +00:00
rostests [KMTEST] 2012-04-27 08:50:57 +00:00
wallpaper - Add CMakeLists for wallpaper 2012-02-05 13:43:04 +00:00