This is an archive of the discontinued LLVM Phabricator instance.

[asan] Fix unittest Asan-x86_64-inline-Test crashing on Windows64
ClosedPublic

Authored by wang0109 on Jul 11 2016, 11:27 AM.

Details

Summary

[asan] Fix unittest Asan-x86_64-inline-Test crashing on Windows64

REAL(memcpy) was used in several places in Asan, while REAL(memmove) was not used.
This CL chooses to patch memcpy() first, solving the crash for unittest.

The crash looks like this:

projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Test.exe
=================================================================
==22680==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x000000000000 bp 0x0029d555f590 sp 0x0029d555f438 T0)
==22680==Hint: pc points to the zero page.

AddressSanitizer can not provide additional info.
 SUMMARY: AddressSanitizer: access-violation (<unknown module>)
==22680==ABORTING

Diff Detail

Repository
rL LLVM

Event Timeline

wang0109 updated this revision to Diff 63543.Jul 11 2016, 11:27 AM
wang0109 retitled this revision from to [asan] Fix unittest Asan-x86_64-inline-Test crashing on Windows64.
wang0109 updated this object.
wang0109 added subscribers: etienneb, chrisha.
etienneb added inline comments.Jul 11 2016, 11:29 AM
lib/asan/asan_interceptors.cc
731 ↗(On Diff #63543)

In this case, I won't put the comment.
All interception may fail and leave a null pointer.

Instead, I think we should add CHECK(REAL(func)) for the function we are calling.
Do a grep over the code and add them at the end of the function.

etienneb updated this object.Jul 11 2016, 11:30 AM
etienneb added a subscriber: llvm-commits.
wang0109 updated this revision to Diff 63552.Jul 11 2016, 12:14 PM
  • update diff: assert success of intercepting memcopy()

List of functions with REAL(func) inside the code:

(__cxa_atexit)
(__cxa_throw)
(_except_handler3)
(_except_handler4)
(_longjmp)
(atoi)
(atol)
(atoll)
(bsd_signal)
(calloc)
(CreateThread)
(dispatch_after)
(dispatch_after_f)
(dispatch_async)
(dispatch_group_async)
(dispatch_group_async_f)
(dispatch_source_set_cancel_handler)
(dispatch_source_set_event_handler)
(dispatch_x_f)
(fork)
(func)
(longjmp)
(malloc)
(memcpy)
(memset)
(name)
(NtWaitForWorkViaWorkerFactory)
(pthread_attr_getdetachstate)
(pthread_create)
(RaiseException)
(sigaction)
(siglongjmp)
(signal)
(strcat)
(strcpy)
(strlen)
(strncat)
(strncpy)
(strnlen)
(strtol)
(strtoll)
(swapcontext)
(wcslen)
wang0109 updated this revision to Diff 63553.Jul 11 2016, 12:34 PM
  • update diff: rewrite comment

what about this instead?

*(::__interception::uptr **)&REAL(memmove) =
      (::__interception::uptr *)&REAL(memcpy);
rnk accepted this revision.Jul 11 2016, 12:43 PM
rnk added a reviewer: rnk.
rnk added a subscriber: rnk.

lgtm

This revision is now accepted and ready to land.Jul 11 2016, 12:43 PM
etienneb added inline comments.Jul 11 2016, 1:01 PM
lib/asan/asan_interceptors.cc
734 ↗(On Diff #63553)

Hey, this doesn't compile.

memcopy -> memcpy

wang0109 updated this revision to Diff 63559.Jul 11 2016, 1:04 PM
wang0109 edited edge metadata.
  • update diff: fix typo
This revision was automatically updated to reflect the committed changes.