Is there a way to avoid the “single large stack” of the Win32 model without compromising SEH? I would like to be able to allocate stack frames on the heap as a way to implement coroutines. However, my code currently depends on SEH, and in this article , a few pages below (talks about bypassing exception handlers, my attention):
The operation is rather paranoid with respect to damaged stacks during this traversal of the chain. It checks that all records in the chain are within the stack . (These boundaries are also written in TEB). The OS also checks that all entries are in ascending order on the stack. If you break these rules, the OS will consider the stack to be corrupted and will not be able to handle exceptions. This is one of the reasons why a Win32 application cannot split its stack into several disjoint segments as an innovative method of dealing with stack overflows.
Basically, if an exception occurs, if the current stack stack is outside the "one large stack", the process will be terminated immediately. Not perfect behavior.
Could anyone get around this problem and recycle SEH using a disjoint stack in a native Win32 application? Also, are there any other Win32 dependent "gotchas" with shared stacks?
source share