Conversation

Hi out of curiosity was playin with hardened_malloc to detect memory leak and from observation, seems that it can't detect memry leak issues if I understood it correctly? even I comp'd it with CONFIG_STATS which seems not understandable,here 🤔 Am I mising smtng?
Image
Image
1
Please read github.com/GrapheneOS/har. It's a hardened memory allocator. It defends against exploitation of memory corruption bugs. It's also not intended as a debugging or auditing tool. Memory leaks aren't memory corruption bugs and aren't relevant to what it defends against.
1
2
The stats about you posted also shows that a 16 byte allocation was allocated and freed, and a 32 byte allocation was allocated but not freed. A 12 byte allocation becomes a 20 byte allocation after reserving space for the 8 byte canary, and the next size after 16 bytes is 32.
1
Since it's a useful feature, hardened_malloc has a malloc_info implementation for usage outside Android using the same stats infrastructure. It's the same information provided via malloc_info by Bionic with a slightly cleaned up format. It's not meant to be feature rich though.