You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add array cookie data to existing data structures -> 7781f78
Consider the padding of array cookies when calculating array element counts -> 0817a3a
In case an array cookie is present, instrument the actual starting address of the array instead of the originally allocated address -> 650b1a3
Add instrumentation for array cookies
Unresolved Questions
Should array cookies be instrumented in any way and if so, how? -> for now, only to correctly calculate array sizes
Array Cookie research
Array cookies are a size_t value saving the allocated length of an array. These cookies are allocated under certain conditions when operator new is used to allocate an array.
=> When are array cookies created?
According to [1], an array cookie is not allocated if either of
"the element type T has a trivial destructor […] and the usual (array) deallocation function […] does not take two arguments" or
"the new operator being used is ::operator new [](size_t, void*)"
CXXNewExpr::getAllocatedType as expr->getAllocatedType().isDestructedType() to check whether the array element type has a non-trivial destructor.
=> How are array cookies created?
According to [1]:
array cookies always have size sizeof(size_t)
if align is the maximum alignment of size_t and an element of the array and padding is the maximum of sizeof(size_t} and align bytes:
"The space allocated for the will be the space required by the array itself plus padding bytes"
"The cookie will be stored in the sizeof(size_t) bytes immediately preceding the array
In Clang this is implemented in ItaniumCXXABI::InitializeArrayCookie.
This is a tracking issue for the support of array cookies in TypeART.
Steps
Add instrumentation for array cookiesUnresolved Questions
Array Cookie research
Array cookies are a
size_t
value saving the allocated length of an array. These cookies are allocated under certain conditions when operator new is used to allocate an array.=> When are array cookies created?
According to [1], an array cookie is not allocated if either of
new
operator being used is::operator new [](size_t, void*)
"In Clang this is implemented in
CGCXXABI::requiresArrayCookie
using:CXXNewExpr::doesUsualArrayDeleteWantSize
andCXXDeleteExpr::doesUsualArrayDeleteWantSize
to check whether the delet function takes two arguments.CXXNewExpr::getAllocatedType
asexpr->getAllocatedType().isDestructedType()
to check whether the array element type has a non-trivial destructor.=> How are array cookies created?
According to [1]:
sizeof(size_t)
align
is the maximum alignment ofsize_t
and an element of the array andpadding
is the maximum ofsizeof(size_t}
andalign
bytes:padding
bytes"sizeof(size_t)
bytes immediately preceding the arrayIn Clang this is implemented in
ItaniumCXXABI::InitializeArrayCookie
.[1] https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies
The text was updated successfully, but these errors were encountered: