[LLVMdev] Signals: interpreter vs. JIT

Matt Renzelmann mjr at cs.wisc.edu
Sun Aug 9 09:23:27 PDT 2009


Just a quick question on LLVM, signals, and the lli interpreter.  A sample
program is included at the end.  Platform is x86, Linux, 32-bit, GCC 4.2.4.

Does lli -force-interpreter support signals, or is it only the JIT that
does?  The following sample program crashes with lli 2.5 and lli
top-of-tree.

Thanks and regards,
Matt

=============================
#include <stdio.h>
#include <signal.h>
#include <sys/time.h>
#include <string.h>

void sigsegv_handler (int signum) {
    printf ("Uh oh\n");
}

int main (int argc, char **argv) {
    struct sigaction sa2;

    printf ("sigsegv_handler: %p\r\n", &sigsegv_handler);

    /* Install the SIGSEGV handler */
    memset ((void *) &sa2, 0, (size_t) sizeof (sa2));
    sa2.sa_handler = &sigsegv_handler;
    sigaction (SIGSEGV, &sa2, NULL);

    /* Send the SIGSEGV signal.  This initiates JIT compilation of
sigsegv_handler */
    kill (getpid (), SIGSEGV);

    /* When the timer finally fires, assuming sigsegv_handler is still
compiling, LLVM crashes */
    for (;;);
    
    return 0;
}
=============================
/scratch/sym/test_cases/test_signal> lli -force-interpreter main.bc
sigsegv_handler: 0x9b02480
0   lli 0x08741d2e
Segmentation fault

/scratch/sym/test_cases/test_signal> lli main.bc                   
sigsegv_handler: 0xf16ff8
Uh oh




More information about the llvm-dev mailing list