testsuites/validation: fix setjmp UB

Storing the return value of setjmp to a local variable is
undefined behavior.

Fixes #5373.
This commit is contained in:
Gedare Bloom
2025-10-09 09:22:55 -06:00
parent 7ebcccf199
commit cec9935c33

View File

@@ -777,19 +777,15 @@ static void Signal( rtems_signal_set signals )
if ( ctx->interrupt || ctx->nested_request ) { if ( ctx->interrupt || ctx->nested_request ) {
if ( ctx->blocked ) { if ( ctx->blocked ) {
SetFatalHandler( ResumeThreadDispatch, ctx ); SetFatalHandler( ResumeThreadDispatch, ctx );
cpu_self = _Thread_Dispatch_disable(); (void) _Thread_Dispatch_disable();
int jumped = setjmp( ctx->thread_dispatch_context ); if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
/* cpu_self can be clobbered by setjmp/longjmp, so reload it */
cpu_self = _Per_CPU_Get();
if ( jumped == 0 ) {
Block( ctx ); Block( ctx );
} else { } else {
_Thread_Dispatch_unnest( cpu_self ); _Thread_Dispatch_unnest( _Per_CPU_Get() );
} }
cpu_self = _Per_CPU_Get();
if ( ctx->interrupt ) { if ( ctx->interrupt ) {
CallWithinISR( Restart, ctx ); CallWithinISR( Restart, ctx );
} else { } else {