Why a segmentation fault occurs calling a function inside setjmp()?
Clash Royale CLAN TAG #URR8PPP Why a segmentation fault occurs calling a function inside setjmp()? I do not understand why in the function middleFunc() , a segmentation fault is raisen when entry_point(arg) is invoked inside the if ( setjmp(middle) ) statement. middleFunc() entry_point(arg) if ( setjmp(middle) ) #include <stdio.h> #include <setjmp.h> jmp_buf start,middle,end; void finalFunc(void *v) { printf("hellon"); return ; } void middleFunc(void (*entry_point)(void *), void *arg) { //just debug : this does not cause segmentation fault entry_point(arg); if ( setjmp(middle) ){ //this casues the segmentation fault entry_point(arg); //once the entry point (finalFunc) is executed go to jmp_buffer end longjmp(end,1); } else { longjmp(start,1); } } int main(){ if (setjmp(end)){ //exit since finalFunc has been executed return ...