ramosian-glider / sanitizers

0 stars 0 forks source link

mstats() crashes under ASan #110

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 109

* Mac OS X 10.7
* LLVM r160364 and r163674
* Without -faddress-sanitizer, the program runs fine.
* This affects Firefox's "about:memory" feature.
* ASan doesn't print a stack trace for this crash.

#include <malloc/malloc.h>
int main()
{
    struct mstats stats = mstats();
    return 0;
}

clang++ -faddress-sanitizer && ./a.out

==68231== ERROR: AddressSanitizer crashed on unknown address 0x000000000000 (pc 0x000000000000
sp 0x7fff6b3ce9a8 bp 0x7fff6b3ce9f0 T0)

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007fff882524fe in malloc_zone_statistics ()
#2  0x00007fff88252555 in mstats ()
#3  0x0000000100000f30 in main ()

Reported by jruderman on 2012-09-12 02:25:24

ramosian-glider commented 9 years ago
I've committed a dummy implementation of stats callback in Clang r163690, so your code
shouldn't crash now.
This will populate malloc_statistics_t with zeroes.
Will need to dive into ASan's allocator to return reasonable counters.

Reported by ramosian.glider on 2012-09-12 09:42:14

ramosian-glider commented 9 years ago
As of r163716 malloc_zone_statistics() returns reasonable results.

Reported by ramosian.glider on 2012-09-12 15:35:11

ramosian-glider commented 9 years ago
Firefox's about:memory works under ASan now. (Sometimes it calculates a negative heap-unused,
but that could just as easily be a Firefox bug as an ASan bug.)

Thanks!

Reported by jruderman on 2012-09-12 17:33:29

ramosian-glider commented 9 years ago
I believe ASan always returns positive numbers, but if you have a good test to assess
the sanity of the numbers returned by mstat, I'd appreciate that.

Reported by ramosian.glider on 2012-09-12 17:50:41

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:00