Index: ossp-pkg/pth/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/pth/ChangeLog,v rcsdiff -q -kk '-r1.629' '-r1.630' -u '/v/ossp/cvs/ossp-pkg/pth/ChangeLog,v' 2>/dev/null --- ChangeLog 2004/12/03 16:17:54 1.629 +++ ChangeLog 2004/12/03 16:21:08 1.630 @@ -21,6 +21,25 @@ Changes between 2.0.2 and 2.0.3 (12-Sep-2004 to xx-xxx-2004) + *) The pth_uctx_save() and pth_uctx_restore() API functions + unfortunately were broken by design because they are C + _functions_. This leads to one more deadly nesting on the + run-time stack which effectively caused the pth_mctx_restore() + in pth_uctx_restore() to return to the end of pth_uctx_save() + but then the control flow unfortunately returns to the + pth_uctx_restore() caller instead of the pth_uctx_save() caller + because the call to pth_uctx_restore() had already overwritten the + run-time stack position where the original return address for the + pth_uctx_save() call was stored. + + The only workaround would be to #define pth_uctx_save() and + pth_uctx_restore() as C _macros_, but this then would require that + lots of the GNU Pth internals from pth_mctx.c would have to be + exported in the GNU Pth API (which in turn is not acceptable). So, + the only consequence is to remove the two functions again from the + GNU Pth API. + [Ralf S. Engelschall, Stefan Brantschen ] + *) Enhance internal pth_mctx_save() if getcontext(3) is used for the machine context saving by better emulating the setjmp(3) style return code semantics. Index: ossp-pkg/pth/THANKS RCS File: /v/ossp/cvs/ossp-pkg/pth/THANKS,v rcsdiff -q -kk '-r1.97' '-r1.98' -u '/v/ossp/cvs/ossp-pkg/pth/THANKS,v' 2>/dev/null --- THANKS 2004/10/08 16:17:02 1.97 +++ THANKS 2004/12/03 16:21:08 1.98 @@ -22,6 +22,7 @@ o Felix Berger o Paolo Bonzini o Raphael Bossek + o Stefan Brantschen o Edwin Brown o Dan Buckler o Mark Burton Index: ossp-pkg/pth/pth.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.h.in,v rcsdiff -q -kk '-r1.143' '-r1.144' -u '/v/ossp/cvs/ossp-pkg/pth/pth.h.in,v' 2>/dev/null --- pth.h.in 2004/10/08 16:17:02 1.143 +++ pth.h.in 2004/12/03 16:21:08 1.144 @@ -505,8 +505,6 @@ /* user-space context functions */ extern int pth_uctx_create(pth_uctx_t *); extern int pth_uctx_make(pth_uctx_t, char *, size_t, const sigset_t *, void (*)(void *), void *, pth_uctx_t); -extern int pth_uctx_save(pth_uctx_t); -extern int pth_uctx_restore(pth_uctx_t); extern int pth_uctx_switch(pth_uctx_t, pth_uctx_t); extern int pth_uctx_destroy(pth_uctx_t); Index: ossp-pkg/pth/pth.pod RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.pod,v rcsdiff -q -kk '-r1.164' '-r1.165' -u '/v/ossp/cvs/ossp-pkg/pth/pth.pod,v' 2>/dev/null --- pth.pod 2004/10/08 16:17:02 1.164 +++ pth.pod 2004/12/03 16:21:08 1.165 @@ -142,8 +142,6 @@ pth_uctx_create, pth_uctx_make, -pth_uctx_save, -pth_uctx_restore, pth_uctx_switch, pth_uctx_destroy. @@ -1520,8 +1518,8 @@ This function creates a user-space context and stores it into I. There is still no underlying user-space context configured. You still -have to do this with pth_uctx_make(3) or pth_uctx_set(3). On success, -this function returns C, else C. +have to do this with pth_uctx_make(3). On success, this function returns +C, else C. =item int B(pth_uctx_t I, char *I, size_t I, const sigset_t *I, void (*I)(void *), void *I, pth_uctx_t I); @@ -1538,41 +1536,24 @@ after POSIX makecontext(3). On success, this function returns C, else C. -=item int B(pth_uctx_t I); - -This function saves the current user-space context in I for later -restoring by either pth_uctx_restore(3) or pth_uctx_switch(3). This -function is somewhat modeled after POSIX getcontext(3). If I is -C, C is returned instead of C. This is the only error -possible. - -=item int B(pth_uctx_t I); - -This function restores the current user-space context from I, -which previously had to be set with either pth_uctx_make(3) or -pth_uctx_save(3). This function is somewhat modeled after POSIX -setcontext(3). If I is C or I contains no valid -user-space context, C is returned instead of C. These are -the only errors possible. - =item int B(pth_uctx_t I, pth_uctx_t I); This function saves the current user-space context in I for -later restoring by either pth_uctx_restore(3) or pth_uctx_switch(3) and -restores the new user-space context from I, which previously -had to be set with either pth_uctx_make(3) or pth_uctx_save(3). This -function is somewhat modeled after POSIX swapcontext(3). If I -or I are C or if I contains no valid user-space -context, C is returned instead of C. These are the only -errors possible. +later restoring by another call to pth_uctx_switch(3) and restores +the new user-space context from I, which previously had to +be set with either a previous call to pth_uctx_switch(3) or initially +by pth_uctx_make(3). This function is somewhat modeled after POSIX +swapcontext(3). If I or I are C or if +I contains no valid user-space context, C is returned +instead of C. These are the only errors possible. =item int B(pth_uctx_t I); This function destroys the user-space context in I. The run-time stack associated with the user-space context is deallocated only if it -was given by the application (see I of pth_uctx_create(3)). -If I is C, C is returned instead of C. This -is the only error possible. +was not given by the application (see I of pth_uctx_create(3)). +If I is C, C is returned instead of C. This is +the only error possible. =back Index: ossp-pkg/pth/pth_uctx.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_uctx.c,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/pth/pth_uctx.c,v' 2>/dev/null --- pth_uctx.c 2004/07/13 10:50:49 1.3 +++ pth_uctx.c 2004/12/03 16:21:08 1.4 @@ -97,7 +97,7 @@ /* switch to successor user-space context */ if (ctx.uctx_after != NULL) - pth_uctx_restore(ctx.uctx_after); + pth_mctx_restore(&(ctx.uctx_after->uc_mctx)); /* terminate process (the only reasonable thing to do here) */ exit(0); @@ -150,7 +150,7 @@ sigprocmask(SIG_SETMASK, sigmask, &ss); /* perform the trampoline step */ - pth_mctx_switch(&mctx_parent, &uctx->uc_mctx); + pth_mctx_switch(&mctx_parent, &(uctx->uc_mctx)); /* optionally restore original signal mask */ if (sigmask != NULL) @@ -162,39 +162,6 @@ return TRUE; } -/* save current user-space context */ -int -pth_uctx_save( - pth_uctx_t uctx) -{ - /* argument sanity checking */ - if (uctx == NULL) - return pth_error(FALSE, EINVAL); - - /* save underlying machine context */ - pth_mctx_save(&uctx->uc_mctx); - uctx->uc_mctx_set = TRUE; - - return TRUE; -} - -/* restore current user-space context */ -int -pth_uctx_restore( - pth_uctx_t uctx) -{ - /* argument sanity checking */ - if (uctx == NULL) - return pth_error(FALSE, EINVAL); - if (!(uctx->uc_mctx_set)) - return pth_error(FALSE, EPERM); - - /* restore underlying machine context */ - pth_mctx_restore(&uctx->uc_mctx); - - return TRUE; -} - /* switch from current to other user-space context */ int pth_uctx_switch( @@ -209,7 +176,7 @@ /* switch underlying machine context */ uctx_from->uc_mctx_set = TRUE; - pth_mctx_switch(&uctx_from->uc_mctx, &uctx_to->uc_mctx); + pth_mctx_switch(&(uctx_from->uc_mctx), &(uctx_to->uc_mctx)); return TRUE; }