On Thu, Feb 04, 2016 at 12:38:54PM +0100, Bert Huijben wrote:
>
>
> > -----Original Message-----
> > From: philip_at_apache.org [mailto:philip_at_apache.org]
> > Sent: woensdag 3 februari 2016 15:27
> > To: commits_at_subversion.apache.org
> > Subject: svn commit: r1728324 -
> > /subversion/trunk/subversion/tests/svn_test_main.c
> >
> > Author: philip
> > Date: Wed Feb 3 14:27:01 2016
> > New Revision: 1728324
> >
> > URL: http://svn.apache.org/viewvc?rev=1728324&view=rev
> > Log:
> > * subversion/tests/svn_test_main.c
> > (call_setjmp): New, to fix some potential setjmp/longjmp clobbers.
> > (do_test_num): Call new function, tweak comment to explain why
> > a parameter is modified.
> >
> > Modified:
> > subversion/trunk/subversion/tests/svn_test_main.c
> >
> > Modified: subversion/trunk/subversion/tests/svn_test_main.c
> > URL:
> > http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test
> > _main.c?rev=1728324&r1=1728323&r2=1728324&view=diff
> > ==========================================================
> > ====================
> > --- subversion/trunk/subversion/tests/svn_test_main.c (original)
> > +++ subversion/trunk/subversion/tests/svn_test_main.c Wed Feb 3
> > 14:27:01 2016
> > @@ -393,6 +393,16 @@ log_results(const char *progname,
> > return test_failed;
> > }
> >
> > +/* This function exists so that automatic variables in the calling
> > + function are peserved. At the time of writing 'err' and 'test_num'
> > + in 'do_test_num()' were in danger of being clobbered by a direct
> > + setjmp() call. */
> > +static int call_setjmp(jmp_buf env)
> > +{
> > + return setjmp(env);
>
> I don't think this is allowed.
>
> Setjmp is not really a function that you can just call from an inner function. As a macro it stores the current stack state, to allow a later return by resetting the stack to the old state. With an inner function this is not guaranteed to work. (I'm guessing many compilers would just inline the single call, but then...)
>
> Bert
>
>
Isn't the right fix to mark the affected variables as volatile?
Received on 2016-02-04 12:47:49 CET