[PATCH] malloc: Add lock to heap consistency check
Kjetil Oftedal
oftedal at gmail.com
Tue Sep 24 11:38:52 UTC 2019
The heap consitency check was unprotected leading to false heap errors
being reported in multithreaded applications.
Signed-off-by: Kjetil Oftedal <oftedal at gmail.com>
---
libc/stdlib/malloc/malloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index f6bf10a..485aac3 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -204,8 +204,11 @@ malloc (size_t size)
debugging_initialized = 1;
__malloc_debug_init ();
}
- if (__malloc_check)
+ if (__malloc_check) {
+ __heap_lock (&__malloc_heap_lock);
__heap_check (__malloc_heap, "malloc");
+ __heap_unlock (&__malloc_heap_lock);
+ }
#endif
#ifdef __MALLOC_GLIBC_COMPAT__
--
1.7.9.5
More information about the uClibc
mailing list