[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] libunwind bug

From: Peter A. Buhr
Subject: [Libunwind-devel] libunwind bug
Date: Fri, 13 Feb 2009 13:47:17 -0500

The following appears to be a libunwind bug with respect to context switching
and timeslicing, which occurs in our threading package. The program below is
the simplest example that generates the failure. Here are additional
environment details. Please contact me if you require additional details.

@plg4[1]% uname -a
Linux 2.6.25-2-mckinley #2 SMP Fri Jun 27 05:32:44 UTC 2008 
ia64 GNU/Linux
@plg4[2]% g++ -v
Using built-in specs.
Target: ia64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1' 
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared 
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext 
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug 
--enable-objc-gc --enable-mpfr --disable-libssp --with-system-libunwind 
--enable-checking=release --build=ia64-linux-gnu --host=ia64-linux-gnu 
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc'
 /usr/lib/gcc/ia64-linux-gnu/4.3.2/cc1plus -quiet -v -D_GNU_SOURCE 
-quiet -dumpbase -auxbase test -version -o /tmp/ccgGQUbV.s
ignoring nonexistent directory "/usr/local/include/ia64-linux-gnu"
ignoring nonexistent directory 
ignoring nonexistent directory "/usr/include/ia64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
GNU C++ (Debian 4.3.2-1) version 4.3.2 (ia64-linux-gnu)
        compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 95c628cc090dee6f51aeb20e8aa4faf3
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc'
 as -x -o /tmp/ccWwmhkO.o /tmp/ccgGQUbV.s
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc'
 /usr/lib/gcc/ia64-linux-gnu/4.3.2/collect2 --hash-style=both -dynamic-linker 
/lib/ /usr/lib/gcc/ia64-linux-gnu/4.3.2/../../../crt1.o 
-L/usr/lib/gcc/ia64-linux-gnu/4.3.2 -L/usr/lib/gcc/ia64-linux-gnu/4.3.2 
-L/usr/lib/gcc/ia64-linux-gnu/4.3.2/../../.. /tmp/ccWwmhkO.o -lstdc++ -lm 
-lgcc_s -lunwind -lgcc -lc -lgcc_s -lunwind -lgcc 
@plg4[3]% ldd a.out =>  (0xa000000000000000) => /usr/lib/ (0x2000000000050000) => /lib/ (0x2000000000224000) => /lib/ (0x20000000002f4000) => /lib/ (0x2000000000318000) => /lib/ (0x2000000000360000)
        /lib/ (0x2000000000000000)
@plg4[4]% a.out
Illegal instruction (core dumped)

================================= ================================

#include <signal.h>
#include <sys/time.h>
#include <ucontext.h>
#include <stdlib.h>

ucontext_t main_ctx, eh_ctx, sched_ctx;

char sched_stack[60000];
char eh_stack[60000];

void eh (void) {                                        // the eh context
    for ( ; ; ) {                                       // yes, we loop 
indefinitely ... until we crash
        try {
            throw 42;
        } catch ( int ) { }

void sched (void) {                                     // the scheduler' 
context, all it does is switch back to the eh context
    for ( ; ; ) {
        swapcontext(&sched_ctx, &eh_ctx);               // re-schedule the eh 

void alrm ( int signum ) {                              // signal handler just 
switches (from the eh) to the sched context
    swapcontext(&eh_ctx, &sched_ctx);

int main() {
    eh_ctx.uc_stack.ss_sp = eh_stack;
    eh_ctx.uc_stack.ss_size = sizeof( eh_stack );
    eh_ctx.uc_link = &main_ctx;
    makecontext(&eh_ctx, eh, 0);

    sched_ctx.uc_stack.ss_sp = sched_stack;
    sched_ctx.uc_stack.ss_size = sizeof( sched_stack );
    sched_ctx.uc_link = NULL;
    makecontext(&sched_ctx, sched, 0);

    // interrupt the eh context every 10 ms with a SIGALRM
    itimerval it;    
    it.it_interval.tv_sec = 0;
    it.it_interval.tv_usec = 10000;
    it.it_value.tv_sec = 0;          
    it.it_value.tv_usec = 10000;

    signal (SIGALRM, alrm);
    setitimer( ITIMER_REAL, &it, NULL );

    swapcontext(&main_ctx, &eh_ctx);                    // start the eh context

reply via email to

[Prev in Thread] Current Thread [Next in Thread]