block alloc: add validations around cache_entry lifecyle

Add an option (controlled by an environment variable) perform extra
validations on mem_pool allocated cache entries. When set:

  1) Invalidate cache_entry memory when discarding cache_entry.

  2) When discarding index_state struct, verify that all cache_entries
     were allocated from expected mem_pool.

  3) When discarding mem_pools, invalidate mem_pool memory.

This should provide extra checks that mem_pools and their allocated
cache_entries are being used as expected.

Signed-off-by: Jameson Miller <jamill@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jameson Miller
2018-07-02 19:49:39 +00:00
committed by Junio C Hamano
parent 8e72d67529
commit 8616a2d0cb
5 changed files with 68 additions and 4 deletions

View File

@ -29,7 +29,7 @@ void mem_pool_init(struct mem_pool **mem_pool, size_t initial_size);
/*
* Discard a memory pool and free all the memory it is responsible for.
*/
void mem_pool_discard(struct mem_pool *mem_pool);
void mem_pool_discard(struct mem_pool *mem_pool, int invalidate_memory);
/*
* Alloc memory from the mem_pool.