Re: [Boost-bugs] [Boost C++ Libraries] #12340: Combining boost::context and SEH doesn't work

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12340: Combining boost::context and SEH doesn't work
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-08-02 18:00:59


#12340: Combining boost::context and SEH doesn't work
-------------------------------+---------------------
  Reporter: nicolasbertolo@… | Owner: olli
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: context
   Version: Boost 1.61.0 | Severity: Problem
Resolution: worksforme | Keywords:
-------------------------------+---------------------

Comment (by anonymous):

 Mmmmh, that's good to know.

 It seems to contradict what this example shows:

 https://msdn.microsoft.com/en-
 us/library/windows/desktop/aa366803(v=vs.85).aspx

>This sample does not show how to use the guard page fault to
>"grow" a dynamic array, such as a stack.

 It implies that it is possible to enlarge a stack after a guard page
 fault.

 https://blogs.msdn.microsoft.com/oldnewthing/20060927-07/?p=29563/

 Explains that normal stack growth is implemented using guard pages, so it
 must be legal to extend a stack.

 Also note that the test does not enlarge the stack at all. It simply
 should detect the page fault and leave the function.

 There is something in boost::context that prevents the SEH code from
 catching access violations to the bottom of the stack.

 I made discovery: if at the bottom of the stack there are '''at least 3
 guard pages''' Windows will automatically extend the stack without ever
 letting the exception reach the exception handler, but when it runs out of
 guard pages it will throw a STATUS_STACK_OVERFLOW exception. If at the
 bottom of the stack there is a page marked PAGE_NOACCESS or if there are
 fewer than 3 guard pages a STATUS_ACCESS_VIOLATION exception will be
 thrown which won't pass through the exception filter (this is what IMHO is
 a bug).


 I changed the parameters of the VirtualProtect call in
 protected_fixedsize_stack.hpp

 {{{
 VirtualProtect(vp, traits_type::page_size() '''* 3''', PAGE_READWRITE |
 PAGE_GUARD /*PAGE_NOACCESS*/, & old_options);
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12340#comment:9>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC