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

[v632] Add support for operator new signature introduced in C++17 in libNew (need for TMapFile) #15343

Merged
merged 29 commits into from
Apr 25, 2024

Conversation

pcanal
Copy link
Member

@pcanal pcanal commented Apr 25, 2024

Backport of #14792

Note both the new (catastrophically) or the old operator new are return an address that
are misaligned.  The old version was (and still) is returning a memory address aligned for sizeof(std::max_align_t)
when it is supposed to returned a memory address aligned with __STDCPP_DEFAULT_NEW_ALIGNMENT__ (those
value are usually respectively 8 and 16).

The lame implementation of operator new for std::align_val_t is currently ignoring the passed argument
(see next commits).
Meta data is extended to include the requested alignment (in case we need to call re-alloc)
and the offset from the actual start of the allocated memory since this is no longer
calculatable from just the address of the data and the alignment.

Remove specialization from not R__B64, assume size_t is always the right type
…sss.

Introduce new callback ROOT::Internal::gGetMapFileMallocDesc
The  indicates the displacement between the requested location and the actual memory location
(Essential once we remove the dreaded MAP_FIXED
MAP_FIXED is evil. The mmap documentation states:

... the mapping established by mmap() replacesany previous mappings for the process' pages in the range from addr to addr + len.

and ** literaly ** it will silenty free-up and reuse any allocation done by malloc/new within the requested range.

In bygone days, this worked out okay by simply specifying a "high enough" memory location to avoid overlap.
However we the advent of memory randomization finding an area of memory that is "a priori" guaranteed to
not be used by something else is essentially impossible.

In previous implementation of TMapFile (a long long time ago) having a matching memory location
for the memory map in the client and server was necessary as data pointers (it was even tried
to re-used virtual function table!) were used.  This is no longer the case and thus relaxing
the actual location will not affect the functionality.
This insures that only the intended part of being allocated within the memory mapped file
This is no longer needed
The previous code in R__ListSlowClose and thus TROOT::CloseFiles was incorrectly using TDirectory::Close
on the unrelated class TMapFile :(
In Optimized build it appears that libNew is not used (when it should) during the
execution of dictionary code.  Given than Mac 12/Monterey will be (likely) end of life
in 6 months, there is no benefit in investigating this issue
Copy link

Test Results

    11 files      11 suites   2d 2h 20m 11s ⏱️
 2 624 tests  2 624 ✅ 0 💤 0 ❌
27 083 runs  27 083 ✅ 0 💤 0 ❌

Results for commit b3fae7a.

@pcanal pcanal merged commit 238d1cb into root-project:v6-32-00-patches Apr 25, 2024
14 of 15 checks passed
@pcanal pcanal deleted the v632-13511 branch April 25, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant