-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
5
-
Storage Engines - 2022-10-17
Summary
WiredTiger uses realloc extensively. Because realloc may or may not allocate new memory, there may be latent bugs where the code works when no new memory is created, but may not when new memory is created (and the old memory is freed). Even when memory is freed, that memory may remain readable, with its original content, so bugs may not be always apparent.
The idea is to put a flag on the connection and/or session that changes how __wt_realloc works. In stress mode, instead of calling realloc, we always call malloc, copy to the new memory, and scribble over the old memory before freeing it. Obviously, it will have performance consequences. If the performance is too severe we could make it do the stress alloc every Nth call, with some randomness thrown in. I think this may potentially catch more errors than the address sanitizers we use, which I don't believe would unconditionally return new memory.