mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
A free Windows-compatible Operating System - mirrored from GitHub
7de47192fe
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 |
||
---|---|---|
reactos | ||
rosapps | ||
rostests | ||
wallpaper |