This is an archive of the discontinued LLVM Phabricator instance.

[asan Win64] Fix missing frames in TestCase null_deref
ClosedPublic

Authored by wang0109 on Jul 14 2016, 7:04 PM.

Details

Reviewers
rnk
Summary

TestCase null_deref was failing in Win64:

c:\lipo\work\asan\b_llvm>c:\lipo\work\asan\b_llvm\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output\null_deref.cc.tmp
=================================================================
==5488==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000028 (pc 0x7ff701f91067 bp 0x000c8cf8fbf0 sp 0x000c8cf8fbb0 T0)
==5488==The signal is caused by a READ memory access.
==5488==Hint: address points to the zero page.
    #0 0x7ff701f91066 in NullDeref(int *) C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:15:10
    #1 0x8a0388830a67  (<unknown module>)

The reason was symbols was not initilized. In fact, it was first inited
with a call to stack.Print(), which calls
WinSymbolizerTool::SymbolizePC, then InitializeDbgHelpIfNeeded().

Since the StackWalk was performed before the stack.Print(), stack frames
where not gathered correctly.

There should be a better place to initialize symbols. For now, this
patch makes the test happy.

Diff Detail

Event Timeline

wang0109 updated this revision to Diff 64074.Jul 14 2016, 7:04 PM
wang0109 retitled this revision from to [asan Win64] Fix missing frames in TestCase null_deref.
wang0109 updated this object.
wang0109 added subscribers: chrisha, etienneb.

After patch:

c:\lipo\work\asan\b_llvm>"c:\lipo\work\asan\b_llvm\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output\null_deref.cc.tmp"
=================================================================
==13776==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000028 (pc 0x7ff778b61028 bp 0x00ddaaaffc90 sp 0x00ddaaaffc70 T0)
==13776==The signal is caused by a WRITE memory access.
==13776==Hint: address points to the zero page.
    #0 0x7ff778b61027 in NullDeref(int *) C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:15:10
    #1 0x7ff778b61060 in main C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:21:3
    #2 0x7ff778b91deb in __scrt_common_main_seh f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:255
    #3 0x7ffeee778101  (C:\Windows\system32\KERNEL32.DLL+0x180018101)
    #4 0x7ffeef7ac5b3  (C:\Windows\SYSTEM32\ntdll.dll+0x18005c5b3)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:15:10 in NullDeref(int *)
==13776==ABORTING

Is this the same idea of what that function is doing:

void InitializeDbgHelpIfNeeded() {
wang0109 updated this revision to Diff 64129.Jul 15 2016, 5:20 AM
  • update diff: Reuse InitializeDbgHelpIfNeeded()
rnk accepted this revision.Jul 15 2016, 9:08 AM
rnk added a reviewer: rnk.
rnk added a subscriber: rnk.

lgtm, yeah, I'm pretty sure you're supposed to call SymInitialize before you call StackWalk64.

This revision is now accepted and ready to land.Jul 15 2016, 9:08 AM
etienneb closed this revision.Jul 15 2016, 10:32 AM

Closed by commit rL275580: TestCase null_deref was failing in Win64: (authored by etienneb).