Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Stats collection broken in tideways_realloc() #99

Open
NoiseByNorthwest opened this issue Jul 8, 2020 · 0 comments
Open

Stats collection broken in tideways_realloc() #99

NoiseByNorthwest opened this issue Jul 8, 2020 · 0 comments

Comments

@NoiseByNorthwest
Copy link

NoiseByNorthwest commented Jul 8, 2020

tideways_realloc() does not correctly collect the allocation stats when wrapping the realloc() function.
It currently assumes that:

  • a new allocation is always done, which is not true.
  • a free (of the old memory) is always done, which is not true. Furthermore realloc can be called with NULL as first argument in order to perform an initial allocation.
  • the total allocated memory is always incremented by the size given as 2nd argument, which is not true.

From the manpage man 3 realloc:

The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged in the range from the start of the region up to the minimum of the
old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. If ptr is NULL, then the call is equivalent to malloc(size), for all values of
size; if size is equal to zero, and ptr is not NULL, then the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc(), or
realloc(). If the area pointed to was moved, a free(ptr) is done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant