OSDN Git Service

Fix race in malloc debug option free_track.
authorChristopher Ferris <cferris@google.com>
Wed, 16 Mar 2016 05:39:39 +0000 (22:39 -0700)
committerChristopher Ferris <cferris@google.com>
Thu, 17 Mar 2016 00:38:08 +0000 (17:38 -0700)
commitd0919623a2ef56107590eca9a9522a250fb8bd4a
treeb0e66ab45ca64f3fb90e03205ebd814f5c55c4f0
parent8d0af0bf8004c65f13b985643004a915d7e382eb
Fix race in malloc debug option free_track.

The free track mechanism could fail if, at the same time a free occurs,
another thread is trying to free and verify the same allocation. This
doesn't work if the freed allocation is added to the list and we still
do work on it. The fix is to only add to the free list when we are done
with the allocation.

Also fix a problem where the usable size is computed incorrectly because
two of the arguments where reversed.

In addition, add a check that the allocation being verified has the correct
tag before trying to check the body of the allocation.

Add a test to catch the original failure.

Add a test for the tag being different.

Bug: 27601650
Change-Id: Ie9200677d066255b8e668a48422f23f909f4ddee
libc/malloc_debug/FreeTrackData.cpp
libc/malloc_debug/malloc_debug.cpp
libc/malloc_debug/tests/malloc_debug_unit_tests.cpp