Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84133 - in trunk: boost/context/detail libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2013-05-04 01:08:43


Author: olli
Date: 2013-05-04 01:08:42 EDT (Sat, 04 May 2013)
New Revision: 84133
URL: http://svn.boost.org/trac/boost/changeset/84133

Log:
context: fix for bug #8544 (Win32 only)

Text files modified:
   trunk/boost/context/detail/fcontext_i386_win.hpp | 4 +
   trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm | 103 ++++++++++++++++++++++-----------------
   trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm | 10 +++
   3 files changed, 69 insertions(+), 48 deletions(-)

Modified: trunk/boost/context/detail/fcontext_i386_win.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_i386_win.hpp (original)
+++ trunk/boost/context/detail/fcontext_i386_win.hpp 2013-05-04 01:08:42 EDT (Sat, 04 May 2013)
@@ -61,13 +61,15 @@
     void * fc_excpt_lst;
     void * fc_local_storage;
     fp_t fc_fp;
+ boost::uint32_t fc_dealloc;
 
     fcontext_t() :
         fc_greg(),
         fc_stack(),
         fc_excpt_lst( 0),
         fc_local_storage( 0),
- fc_fp()
+ fc_fp(),
+ fc_dealloc( 0)
     {}
 };
 

Modified: trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm 2013-05-04 01:08:42 EDT (Sat, 04 May 2013)
@@ -39,6 +39,13 @@
 ; --------------------------------------------------------------
 ; | fc_mxcsr|fc_x87_cw| |
 ; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 13 | |
+; --------------------------------------------------------------
+; | 034h | |
+; --------------------------------------------------------------
+; |fc_deallo| |
+; --------------------------------------------------------------
 
 .386
 .XMM
@@ -46,62 +53,66 @@
 .code
 
 jump_fcontext PROC EXPORT
- mov ecx, [esp+04h] ; load address of the first fcontext_t arg
- mov [ecx], edi ; save EDI
- mov [ecx+04h], esi ; save ESI
- mov [ecx+08h], ebx ; save EBX
- mov [ecx+0ch], ebp ; save EBP
+ mov ecx, [esp+04h] ; load address of the first fcontext_t arg
+ mov [ecx], edi ; save EDI
+ mov [ecx+04h], esi ; save ESI
+ mov [ecx+08h], ebx ; save EBX
+ mov [ecx+0ch], ebp ; save EBP
 
     assume fs:nothing
- mov edx, fs:[018h] ; load NT_TIB
+ mov edx, fs:[018h] ; load NT_TIB
     assume fs:error
- mov eax, [edx] ; load current SEH exception list
- mov [ecx+024h], eax ; save current exception list
- mov eax, [edx+04h] ; load current stack base
- mov [ecx+018h], eax ; save current stack base
- mov eax, [edx+08h] ; load current stack limit
- mov [ecx+020h], eax ; save current stack limit
- mov eax, [edx+010h] ; load fiber local storage
- mov [ecx+028h], eax ; save fiber local storage
-
- lea eax, [esp+04h] ; exclude the return address
- mov [ecx+010h], eax ; save as stack pointer
- mov eax, [esp] ; load return address
- mov [ecx+014h], eax ; save return address
-
- mov edx, [esp+08h] ; load address of the second fcontext_t arg
- mov edi, [edx] ; restore EDI
- mov esi, [edx+04h] ; restore ESI
- mov ebx, [edx+08h] ; restore EBX
- mov ebp, [edx+0ch] ; restore EBP
+ mov eax, [edx] ; load current SEH exception list
+ mov [ecx+024h], eax ; save current exception list
+ mov eax, [edx+04h] ; load current stack base
+ mov [ecx+018h], eax ; save current stack base
+ mov eax, [edx+08h] ; load current stack limit
+ mov [ecx+020h], eax ; save current stack limit
+ mov eax, [edx+0e0ch] ; load current deallocation stack
+ mov [ecx+034h], eax ; save current deallocation stack
+ mov eax, [edx+010h] ; load fiber local storage
+ mov [ecx+028h], eax ; save fiber local storage
+
+ lea eax, [esp+04h] ; exclude the return address
+ mov [ecx+010h], eax ; save as stack pointer
+ mov eax, [esp] ; load return address
+ mov [ecx+014h], eax ; save return address
+
+ mov edx, [esp+08h] ; load address of the second fcontext_t arg
+ mov edi, [edx] ; restore EDI
+ mov esi, [edx+04h] ; restore ESI
+ mov ebx, [edx+08h] ; restore EBX
+ mov ebp, [edx+0ch] ; restore EBP
 
- mov eax, [esp+010h] ; check if fpu enve preserving was requested
+ mov eax, [esp+010h] ; check if fpu enve preserving was requested
     test eax, eax
     je nxt
 
- stmxcsr [ecx+02ch] ; save MMX control word
- fnstcw [ecx+030h] ; save x87 control word
- ldmxcsr [edx+02ch] ; restore MMX control word
- fldcw [edx+030h] ; restore x87 control word
+ stmxcsr [ecx+02ch] ; save MMX control word
+ fnstcw [ecx+030h] ; save x87 control word
+ ldmxcsr [edx+02ch] ; restore MMX control word
+ fldcw [edx+030h] ; restore x87 control word
 nxt:
- mov ecx, edx
+ mov ecx, edx
     assume fs:nothing
- mov edx, fs:[018h] ; load NT_TIB
+ mov edx, fs:[018h] ; load NT_TIB
     assume fs:error
- mov eax, [ecx+024h] ; load SEH exception list
- mov [edx], eax ; restore next SEH item
- mov eax, [ecx+018h] ; load stack base
- mov [edx+04h], eax ; restore stack base
- mov eax, [ecx+020h] ; load stack limit
- mov [edx+08h], eax ; restore stack limit
- mov eax, [ecx+028h] ; load fiber local storage
- mov [edx+010h], eax ; restore fiber local storage
-
- mov eax, [esp+0ch] ; use third arg as return value after jump
-
- mov esp, [ecx+010h] ; restore ESP
- mov [esp+04h], eax ; use third arg as first arg in context function
- mov ecx, [ecx+014h] ; fetch the address to return to
+ mov eax, [ecx+024h] ; load SEH exception list
+ mov [edx], eax ; restore next SEH item
+ mov eax, [ecx+018h] ; load stack base
+ mov [edx+04h], eax ; restore stack base
+ mov eax, [ecx+020h] ; load stack limit
+ mov [edx+08h], eax ; restore stack limit
+ mov eax, [ecx+034h] ; load deallocation stack
+ mov [edx+0e0ch], eax ; restore deallocation stack
+ mov eax, [ecx+028h] ; load fiber local storage
+ mov [edx+010h], eax ; restore fiber local storage
+
+ mov eax, [esp+0ch] ; use third arg as return value after jump
+
+ mov esp, [ecx+010h] ; restore ESP
+ mov [esp+04h], eax ; use third arg as first arg in context function
+ mov ecx, [ecx+014h] ; fetch the address to return to
 
     jmp ecx ; indirect jump to context
 jump_fcontext ENDP

Modified: trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm 2013-05-04 01:08:42 EDT (Sat, 04 May 2013)
@@ -39,6 +39,13 @@
 ; --------------------------------------------------------------
 ; | fc_mxcsr|fc_x87_cw| |
 ; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 13 | |
+; --------------------------------------------------------------
+; | 034h | |
+; --------------------------------------------------------------
+; |fc_deallo| |
+; --------------------------------------------------------------
 
 .386
 .XMM
@@ -48,7 +55,7 @@
 
 make_fcontext PROC EXPORT
     mov eax, [esp+04h] ; load 1. arg of make_fcontext, pointer to context stack (base)
- lea eax, [eax-034h] ; reserve space for fcontext_t at top of context stack
+ lea eax, [eax-038h] ; reserve space for fcontext_t at top of context stack
 
     ; shift address in EAX to lower 16 byte boundary
     ; == pointer to fcontext_t and address of context stack
@@ -61,6 +68,7 @@
     neg edx ; negate stack size for LEA instruction (== substraction)
     lea ecx, [ecx+edx] ; compute bottom address of context stack (limit)
     mov [eax+020h], ecx ; save address of context stack (limit) in fcontext_t
+ mov [eax+034h], ecx ; save address of context stack limit as 'dealloction stack'
     mov ecx, [esp+0ch] ; load 3. arg of make_fcontext, pointer to context function
     mov [eax+014h], ecx ; save address of context function in fcontext_t
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk