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
In some type-punned fields, we make assumptions that the alignment is smaller than alignof(std::max_align_t).
Reproducer
This breaks in certain combinations of types, for example a std::vector of an over-aligned type:
#include<ROOT/RNTupleModel.hxx>
#include<ROOT/RNTupleReader.hxx>
#include<ROOT/RNTupleWriter.hxx>
#include<sstream>
#include<vector>structalignas(64) CacheLine {
int i = 0;
};
voidntuple_aligned() {
auto model = ROOT::Experimental::RNTupleModel::Create();
using Vector = std::vector<CacheLine>;
model->MakeField<Vector>("v");
{
auto writeModel = model->Clone();
auto vPtr = writeModel->GetDefaultEntry().GetPtr<Vector>("v");
auto writer = ROOT::Experimental::RNTupleWriter::Recreate(std::move(writeModel), "ntuple", "ntuple_aligned.root");
vPtr->push_back({});
writer->Fill();
}
auto readModel = model->Clone();
auto vPtr = readModel->GetDefaultEntry().GetPtr<Vector>("v");
auto reader = ROOT::Experimental::RNTupleReader::Open(std::move(readModel), "ntuple", "ntuple_aligned.root");
reader->LoadEntry(0);
auto ptr = &vPtr->at(0);
auto uptr = reinterpret_cast<std::uintptr_t>(ptr);
// Do a small dance to prevent the compiler from optimizing the alignment check...
std::stringstream ss;
ss << uptr;
ss >> uptr;
std::cout << ptr << " (" << uptr << ") % 64 = " << (uptr % 64) << std::endl;
}
possible output:
0x48c9230 (76321328) % 64 = 48
The text was updated successfully, but these errors were encountered:
Some other fields try to get this right, for example RRecordField. We should investigate if we can make std::vector<char> allocate over-aligned memory areas. The other option is to forbid over-aligned types (and possibly simplify some other code).
Description
In some type-punned fields, we make assumptions that the alignment is smaller than
alignof(std::max_align_t)
.Reproducer
This breaks in certain combinations of types, for example a
std::vector
of an over-aligned type:possible output:
The text was updated successfully, but these errors were encountered: