> "Oliver Kowalke" <oliver.kowalke@xxxxxx> writes: > > > What marks the end of stack or how does uw_frame_state_for() detect the > end of stack? > > I've a coroutine library and I'm using _Unwind_ForcedUnwind() for stack > cleanup. Function _Unwind_ForcedUnwind_Phase2() never sets > _URC_END_OF_STACK! > > What happens when it goes past the top of the stack? I get an segmentation fault from _Uwind_resume(). > Normally the unwinder returns _URC_END_OF_STACK when it finds a stack > frame with a PC value with no associated FDE. A specific such PC value > is zero. In the example _URC_END_OF_STACK is not returned. A simple memory chunk is used as stack. Maybe I've to append a special page at the end of the stack - or something else? I hopefuly the issue can be fixed. best regards, Oliver test code with segfault: #include <ucontext.h> #include <unwind.h> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> static int counter = 0; static ucontext_t ucf, ucm; struct X { X() { std::cout << "X()" << std::endl; } ~X() { std::cout << "~X()" << std::endl; } }; _Unwind_Reason_Code stop( int version, _Unwind_Action actions, _Unwind_Exception_Class exc_class, _Unwind_Exception *exc, _Unwind_Context *context, void * param) { // std::cout << "counter == " << ++counter << std::endl; if ( actions & _UA_END_OF_STACK) { std::cout << "end of stack, jump back" << std::endl; _Unwind_DeleteException( exc); if ( ::swapcontext( & ucf, & ucm) == -1) ::abort(); } return _URC_NO_REASON; } void force_unwind() { _Unwind_Exception * exc = new _Unwind_Exception; std::memset( exc, 0, sizeof( * exc) ); _Unwind_ForcedUnwind( exc, stop, 0); } void f( int i) { if ( i > 0) { X x; f( --i); } else { force_unwind(); std::cout << "fini" << std::endl; } } int main( int argc, char * argv[]) { std::vector< char > fn_stack(16384, '\0'); if ( ::getcontext( & ucf) == -1) ::abort(); ucf.uc_stack.ss_sp = & fn_stack[0]; ucf.uc_stack.ss_size = fn_stack.size(); ::makecontext( & ucf, (void(*)())( f), 1, 5); if ( ::swapcontext( & ucm, & ucf) == -1) ::abort(); std::cout << "done" << std::endl; return 0; } -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de