From: Mathieu Bouchard Date: 2003-07-13T13:56:52+09:00 Subject: Re: stack problem On Sat, 12 Jul 2003, Mauricio Fern�ndez wrote: > You can use Init_stack, see the thread starting at [ruby-talk:74400]. Thanks. If I understood correctly, I have to use it like this? volatile long bogus_variable = 0; /* just even *try* to optimise me out of existence! */ sigjmp_buf rescue_segfault; static void trap_segfault (int patate) { fprintf(stderr,"THIS IS INSIDE A SIGHANDLER!\n"); siglongjmp(rescue_segfault,11); } extern "C" void Init_stack(VALUE *addr); static void bridge_localize_sysstack () { volatile long * volatile bp = (volatile long *)&bp; /* get any stack address */ fprintf(stderr,"sysstack top is at 0x%08lx\n",(long)bp); post("sysstack top is at 0x%08lx\n",(long)bp); signal(11,trap_segfault); // in this loop, segfault is overridden to mean breaking out of the for-loop. if (!sigsetjmp(rescue_segfault,0)) { for (;;) { //fprintf(stderr,"sysstack: trying 0x%08lx\n",(long)bp); bp+=1; bogus_variable += *bp; } } bp-=1; signal(11,SIG_DFL); /* can't really restore it. don't know where it was. */ fprintf(stderr,"sysstack starts at 0x%08lx\n",(long)bp); post("sysstack starts at 0x%08lx\n",(long)bp); Init_stack((VALUE *)bp); } ________________________________________________________________ Mathieu Bouchard http://artengine.ca/matju