Bionic: Fix some issues in chk_malloc

1. Revise log_message in chk_malloc
a) Race condition issues may occur when malloc/free are dispatched between
dlmalloc/dlfree and chk_malloc/chk_free when libc.debug.malloc=10 is set.

log_message reverts chk_malloc/chk_free to default dlmalloc/dlfree, but
that's not safe if other threads are trying to call malloc/free. This
may lead mismatched to chk_malloc/chk_free and malloc/free calls. Use a
lock instead.

b) But still a potential deadlock (recursively call the same non-recursive-lock)
with backlog_lock/lock will occur if log_message called from chk_malloc
/chk_free tries to call chk_malloc/chk_free again.

In mem chunk meta, ALLOC_NONCHK_TAG is added to avoid chunks allocated
in log_message being added to the memleak/doublefree track lists and
being checked to make sure no non-recur-lock will be called recursively.

2. Race issue in heaptracker
a) Travel the list in heaptracker_free_leaked_memory() without fully
holding locks will result in race condition.
Locks are added to deal with it.

b) If corruptions were found without removing the chunk from the chunk list
e.g. backlog list, list corruptions will come out with broken list pointers
as dlfree will change the meta data.
abort() will be called directly after corruptions are found in
check_allocation_locked() to report errors as early as possible.

3. Align chk_realloc with dlrealloc
The old mem pointer passed to chk_realloc should be checked first especially
when the size equals to zero. If not, chk_realloc will return NULL which
means no mem left and results in fatal errors.
This change will align chk_realloc with dlrealloc.
REALLOC_ZERO_BYTES_FREES defined in bionic/libc/Android.mk is also added
into chk_malloc to keep alignment.

Change-Id: I537bdf7df98bb00dc504a9d3fd0a54f9ddcd9295
Author: Du Chenyang <chenyang.du@intel.com>
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Author-tracking-BZ: 53674