On Tue, 2012-11-20 at 23:19 -0500, David Miller wrote: > The address violation detection seems to work properly and the only > thing that seems to be left are some backtrace/unwind issues. These > are perhaps similar to the unwind bits that the powerpc folks ran > into.
David, does the following patch (will have some fuzz since I removed one ppc only hunk from the patch) fix your backtrace issue? I'll note you'll have to add "|| defined(__sparc__)" to the #if ... or as it's probably going to turn out, just replace the whole thing with a "#if !defined(__i386__) && !defined(__x86_64__)". Peter Index: libsanitizer/asan/asan_linux.cc =================================================================== --- libsanitizer/asan/asan_linux.cc (revision 193678) +++ libsanitizer/asan/asan_linux.cc (working copy) @@ -134,11 +141,27 @@ #endif } +uptr Unwind_GetBP(struct _Unwind_Context *ctx) { + return _Unwind_GetCFA(ctx); +} + +struct Unwind_Trace_Info { + StackTrace *stack; + uptr bp; +}; + _Unwind_Reason_Code Unwind_Trace(struct _Unwind_Context *ctx, void *param) { - StackTrace *b = (StackTrace*)param; + Unwind_Trace_Info *p = (Unwind_Trace_Info *)param; + StackTrace *b = p->stack; + uptr pc = Unwind_GetIP(ctx); + if (Unwind_GetBP(ctx) == p->bp) { + // We just encountered the frame pointer we want to start + // our backtrace with, so empty the backtrace before adding + // this frame to the backtrace. + b->size = 0; + } CHECK(b->size < b->max_size); - uptr pc = Unwind_GetIP(ctx); b->trace[b->size++] = pc; if (b->size == b->max_size) return UNWIND_STOP; return UNWIND_CONTINUE; @@ -149,8 +172,11 @@ stack->trace[0] = pc; if ((max_s) > 1) { stack->max_size = max_s; -#ifdef __arm__ - _Unwind_Backtrace(Unwind_Trace, stack); +#if defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__) + Unwind_Trace_Info param; + param.stack = stack; + param.bp = bp; + _Unwind_Backtrace(Unwind_Trace, ¶m); #else if (!asan_inited) return; if (AsanThread *t = asanThreadRegistry().GetCurrent())