This is an archive of the discontinued LLVM Phabricator instance.

[AddressSanitizer] [Windows] Fix HeapReAlloc and _recalloc bugs in asan_malloc_win.cc
ClosedPublic

Authored by mcgov on Apr 29 2019, 10:19 AM.

Details

Summary

HeapReAlloc should allow for 0 sized reallocations without freeing the memory block provided by the user.

_recalloc previously did not zero new memory after reallocation.

Diff Detail

Event Timeline

mcgov created this revision.Apr 29 2019, 10:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2019, 10:19 AM
mcgov planned changes to this revision.Apr 29 2019, 10:28 AM
mcgov updated this revision to Diff 197143.Apr 29 2019, 10:37 AM

adding tests for correct behaviors

Ready for review

Let first land NFC reformatting part of this patch?
And rebase this patch on top of the NFC one.

Let first land NFC reformatting part of this patch?
And rebase this patch on top of the NFC one.

That's a good idea, I'll do that now.

mcgov planned changes to this revision.Apr 29 2019, 11:06 AM
rnk added a comment.Apr 29 2019, 11:16 AM

Watch out for compiler-rt/lib/sanitizer_common/scripts/check_lint.sh, sometimes it disagrees with what clang-format does. It runs as part of check-sanitizer on Linux but not Windows. I have run into this accidentally numerous times. If you don't want to worry about that, consider using git-clang-format to avoid reformatting lines not affected by your patch.

Functionality seems good, thanks!

mcgov updated this revision to Diff 197163.Apr 29 2019, 12:40 PM
mcgov edited the summary of this revision. (Show Details)
mcgov set the repository for this revision to rCRT Compiler Runtime.

Update diff to only apply clang-format to new code

mcgov updated this revision to Diff 197166.Apr 29 2019, 12:47 PM

fix call to get_usable_size so that it is not called unless HEAP_ZERO_MEMORY is passed in (the only case when it is needed).

Ready for review (clang-format only applied to new code)

LGTM

compiler-rt/lib/asan/asan_malloc_win.cc
147

not formated?

rnk added inline comments.Apr 29 2019, 1:01 PM
compiler-rt/lib/asan/asan_malloc_win.cc
23

I don't think this is needed, you can use u8 * instead which is more common across the rest of the ASan runtime.

147

Make sure this is just 2 space indentation.

mcgov updated this revision to Diff 197171.Apr 29 2019, 1:05 PM

fix BYTE typdef and incorrect format

rnk accepted this revision.Apr 29 2019, 1:09 PM

lgtm, thanks!

This revision is now accepted and ready to land.Apr 29 2019, 1:09 PM
mcgov closed this revision.Apr 29 2019, 1:24 PM
mcgov marked 2 inline comments as done.

closed with revision 359498