Skip to content

Stop managed_array from accidentally changing C++ types#155

Merged
JBenda merged 4 commits into
JBenda:masterfrom
willvale:fix-cpp-type-transmutation
Jul 2, 2026
Merged

Stop managed_array from accidentally changing C++ types#155
JBenda merged 4 commits into
JBenda:masterfrom
willvale:fix-cpp-type-transmutation

Conversation

@willvale

Copy link
Copy Markdown
Contributor

Storing non-POD types in char buffers is unsafe.

  • Ensure alignments are compatible with desired type.
  • Ensure raw data is copied with memcpy

Otherwise, _list_handouts placement-constructs entries as one type (list_impl) which is changed when they're copied by the copy constructor of T (list_interface, different type). For POD data this wouldn't matter, but here it changes the vtable pointer and indirectly causes an OOB write.

This crashed my memory allocator, which is how I spotted it.

willvale added 3 commits June 29, 2026 23:06
Storing non-POD types in char buffers is unsafe.

* Ensure alignments are compatible with desired type.
* Ensure raw data is copied with memcpy

Otherwise, the list entries are created raw and placement-constructed as one type, which is changed when they're copied by the copy constructor of T (different type). For POD data this wouldn't matter, but here it changes the vtable pointer and indirectly causes an OOB write.
@JBenda

JBenda commented Jun 30, 2026

Copy link
Copy Markdown
Owner

With the new CMake version, the pipeline for Win64 seems broken; I will fix this and then merge this PR.
Thanks for spotting and fixing the memory error.

@willvale

willvale commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, I spotted something was up with the CI but I'm not a CMake user so didn't try and fix.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Ink Proof Results

These results are obtained by running the Ink-Proof Testing Suite on the compiled binaries in this pull request.

System Results
Linux x64 130/130 passed
MacOSX-ARM DISABLED
MacOSX DISABLED
Windows x64 130/130 passed

@JBenda JBenda merged commit 461bc3b into JBenda:master Jul 2, 2026
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants