On Tue, Dec 27, 2011 at 12:22 PM, Joerg Sonnenberger < joerg at britannica.bec.de> wrote:> On Tue, Dec 27, 2011 at 12:10:54PM -0800, Kostya Serebryany wrote: > > What would be the best fix for asan? > > Can you be explicit what you need to asan? Just the equivalent of > __builtin_return_address(0) or do you really need a full stack trace? >asan-rt uses __builtin_return_address(0) to get the full stack trace. See compiler-rt/lib/asan/asan_stack.cc (AsanStackTrace::FastUnwindStack) It checks the current thread's stack bounds to avoid a wild dereference. Asan does not use unsafe __builtin_return_address(N, N>0), although it would be nice if __builtin_return_address(N, N>0) had safer semantics. --kcc> > Joerg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111227/922b6a00/attachment.html>
On Tue, Dec 27, 2011 at 12:35:52PM -0800, Kostya Serebryany wrote:> On Tue, Dec 27, 2011 at 12:22 PM, Joerg Sonnenberger < > joerg at britannica.bec.de> wrote: > > > On Tue, Dec 27, 2011 at 12:10:54PM -0800, Kostya Serebryany wrote: > > > What would be the best fix for asan? > > > > Can you be explicit what you need to asan? Just the equivalent of > > __builtin_return_address(0) or do you really need a full stack trace? > > > > asan-rt uses __builtin_return_address(0) to get the full stack trace. > See compiler-rt/lib/asan/asan_stack.cc (AsanStackTrace::FastUnwindStack) > It checks the current thread's stack bounds to avoid a wild dereference. > > Asan does not use unsafe __builtin_return_address(N, N>0), although it > would be nice if __builtin_return_address(N, N>0) had safer semantics.That's inconsistent :) __builtin_return_address(0) works with or without frame pointer. What doesn't work is depending on the frame pointer on the stack to "speed up" the unwinding further. So what is it? Joerg
On Tue, Dec 27, 2011 at 4:00 PM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:> On Tue, Dec 27, 2011 at 12:35:52PM -0800, Kostya Serebryany wrote: > > On Tue, Dec 27, 2011 at 12:22 PM, Joerg Sonnenberger < > > joerg at britannica.bec.de> wrote: > > > > > On Tue, Dec 27, 2011 at 12:10:54PM -0800, Kostya Serebryany wrote: > > > > What would be the best fix for asan? > > > > > > Can you be explicit what you need to asan? Just the equivalent of > > > __builtin_return_address(0) or do you really need a full stack trace? > > > > > > > asan-rt uses __builtin_return_address(0) to get the full stack trace. > > See compiler-rt/lib/asan/asan_stack.cc (AsanStackTrace::FastUnwindStack) > > It checks the current thread's stack bounds to avoid a wild dereference. > > > > Asan does not use unsafe __builtin_return_address(N, N>0), although it > > would be nice if __builtin_return_address(N, N>0) had safer semantics. > > That's inconsistent :) __builtin_return_address(0) works with or without > frame pointer. What doesn't work is depending on the frame pointer on > the stack to "speed up" the unwinding further. So what is it? >Not sure what your question is. afaict, the method used by asan is the only fast way to get stack traces (but it requires frame pointers). All other methods (e.g. libunwind) are much slower. --kcc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111227/983840e5/attachment.html>
On Wed, Dec 28, 2011 at 12:35 AM, Kostya Serebryany <kcc at google.com> wrote:> > > On Tue, Dec 27, 2011 at 12:22 PM, Joerg Sonnenberger > <joerg at britannica.bec.de> wrote: >> >> On Tue, Dec 27, 2011 at 12:10:54PM -0800, Kostya Serebryany wrote: >> > What would be the best fix for asan? >> >> Can you be explicit what you need to asan? Just the equivalent of >> __builtin_return_address(0) or do you really need a full stack trace? > > > asan-rt usesĀ __builtin_return_address(0) to get the full stack trace. > SeeĀ compiler-rt/lib/asan/asan_stack.cc (AsanStackTrace::FastUnwindStack) > It checks the current thread's stack bounds to avoid a wild dereference. >I think it does not. What you're doing there is traversing the stack frames. __builtin_return_address(0) is generated for each function individually. It just reads the return address from the known position on the stack and does not help to unwind further. I believe the best option for us is to add the --fno-omit-frame-pointer depending on the -faddress-sanitizer flag. But in order to do this reliably, we need to remove all the instances of -fomit-frame-pointer from the command line. IIUC Clang doesn't support this now. -- Alexander Potapenko Software Engineer Google Moscow
> I believe the best option for us is to add the > --fno-omit-frame-pointer depending on the -faddress-sanitizer flag. > But in order to do this reliably, we need to remove all the instances > of -fomit-frame-pointer from the command line.Why? Just add -fno-omit-frame-pointer last. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University