This is an archive of the discontinued LLVM Phabricator instance.

[asan] Use exact comparison in BufferedStackTrace::LocatePcInTrace
Changes PlannedPublic

Authored by vitalybuka on Dec 29 2016, 9:19 PM.

Details

Reviewers
eugenis
Summary

Make sure that BufferedStackTrace in malloc interceptors has top frame
calculated with GET_CALLER_PC.

Replace GET_CURRENT_PC_BP_SP with GET_CURRENT_BP_SP and make code use
GET_CALLER_PC.

Event Timeline

vitalybuka updated this revision to Diff 82717.Dec 29 2016, 9:19 PM
vitalybuka retitled this revision from to [asan] Use exact comparison in BufferedStackTrace::LocatePcInTrace.
vitalybuka updated this object.
vitalybuka added a reviewer: eugenis.
vitalybuka added a subscriber: llvm-commits.
eugenis edited edge metadata.Jan 3 2017, 2:35 PM

What if we used GET_CALLER_PC in the interceptor functions instead of GET_CURRENT_PC_BP_SP? That would provide an address in the user code, which MatchPc could match exactly and take one step back to get the interceptor frame?

Sorry, I still don't like this.
You are basically fixing up the stack trace so it can be reliably re-unwound, but this fixup only holds in the callees of the current function, and it's not clear what the exact set of functions need this and how to maintain this in the future.

As I see it, the problem is not really with the stack trace itself. We are replacing it with a better trace later anyway. The problem is to keep enough information to trim the new trace at the right point.

When malloc_context_size > 1, exact matching trace[1] and then stepping back should work strictly better than the current code. When malloc_context_size<=1, we can keep the current behavior, or add a new field to store caller-pc from the interceptor PoV.

lib/asan/asan_stack.h
63

Please rename to GetStackTraceWithCurrentPcBpAndContext, or something like that

vitalybuka updated this revision to Diff 83179.Jan 4 2017, 7:29 PM
vitalybuka edited edge metadata.

renamed function

vitalybuka marked an inline comment as done.Jan 4 2017, 7:29 PM
vitalybuka updated this revision to Diff 83181.Jan 4 2017, 7:34 PM

UNREACHABLE("Trace must contain PC");

vitalybuka planned changes to this revision.Jan 4 2017, 8:25 PM