rallocm(ALLOCM_ZERO) only zeroes *new* memory
authorTudor Bosman <tudorb@fb.com>
Fri, 13 Jul 2012 22:58:47 +0000 (15:58 -0700)
committerTudor Bosman <tudorb@fb.com>
Fri, 13 Jul 2012 23:30:40 +0000 (16:30 -0700)
commit69e9440b283a807dc636702085861019ea5b926f
tree5026da0f546d6dda38cce81531452c82c1e9cb9e
parent37f182540d67f239b7e29274b92be6e07351a5f3
rallocm(ALLOCM_ZERO) only zeroes *new* memory

Summary:
If you allocate N bytes and then try to grow that in place using rallocm
(ALLOCM_ZERO | ALLOCM_NO_MOVE) to M > N, our code assumed that all
memory from N to M would be zeroed.  In fact, rallocm only zeroes *new*
memory, so if jemalloc actually allocated N1 > N bytes initially,
rallocm will only zero memory from N1 to M.

Fixed by using calloc.

Test Plan: thread_local_test, tested in production

Reviewed By: delong.j@fb.com

FB internal diff: D519781
folly/detail/ThreadLocalDetail.h