NetBSD-Bugs archive

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

re: toolchain/53918: X crashes on pinebook and stack unwinding broken



i hacked the xorg_backtrace() function into a simple test case that
also hangs on arm64 for me.


.mrg.


#include <dlfcn.h>
#include <execinfo.h>
#include <stdio.h>
#include <signal.h>

#define ErrorFSigSafe printf

void
xorg_backtrace(void)
{   
    const int BT_SIZE = 64;
    void *array[BT_SIZE];
    const char *mod;
    int size, i;
    Dl_info info;

    ErrorFSigSafe("\n");
    ErrorFSigSafe("Backtrace:\n");
    size = backtrace(array, BT_SIZE);
    ErrorFSigSafe("bt size = %d\n", size);
    for (i = 0; i < size; i++) {
        int rc = dladdr(array[i], &info);

        if (rc == 0) {
            ErrorFSigSafe("%u: ?? [%p]\n", i, array[i]);
            continue;
        }
        mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
        if (info.dli_saddr)
            ErrorFSigSafe(
                "%u: %s (%s+0x%x) [%p]\n",
                i,
                mod,
                info.dli_sname,
                (unsigned int)((char *) array[i] -
                               (char *) info.dli_saddr),
                array[i]);
        else
            ErrorFSigSafe(
                "%u: %s (%p+0x%x) [%p]\n",
                i,
                mod,
                info.dli_fbase,
                (unsigned int)((char *) array[i] -
                               (char *) info.dli_fbase),
                array[i]);
    }
    ErrorFSigSafe("\n");
}

void
call_bt(int signo)
{
	printf("signo: %d\n", signo);
	xorg_backtrace();
}

int
main(void)
{
	xorg_backtrace();

	signal(SIGSEGV, call_bt);
	*(volatile char *)0 = 1;
}


Home | Main Index | Thread Index | Old Index