Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔬 Tracking issue for array cookie support #71

Closed
9 tasks done
alexanderlinne opened this issue May 7, 2021 · 0 comments
Closed
9 tasks done

🔬 Tracking issue for array cookie support #71

alexanderlinne opened this issue May 7, 2021 · 0 comments
Assignees

Comments

@alexanderlinne
Copy link
Contributor

alexanderlinne commented May 7, 2021

This is a tracking issue for the support of array cookies in TypeART.

Steps

  • Research when and how array cookies are added
  • Add test cases for cases where array cookies are expected to be added -> 65684d7, 22d8b4f
  • Implementation
    • Finding array cookies -> d40d567
    • 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*)"

In Clang this is implemented in CGCXXABI::requiresArrayCookie using:

=> 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.

[1] https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies

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

No branches or pull requests

1 participant