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

Allow producing forward compatible file for fBits value. #15006

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/rootrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ RSA.KeyType: 1
# Enable cross-protocol redirects
TFile.CrossProtocolRedirects: yes

# Force the producing of files forward compatible with (unpatched) version
# of ROOT older than v6.30 by recording the internal bits kIsOnHeap and
# kNotDeleted; Older releases were not explicitly setting those bits to the
# correct value but instead used verbatim the value stored in the file.
# TFile.v630forwardCompatibility: no

# List of S3 servers known to support multi-range HTTP GET requests.
# This is the value sent back by the S3 server in the 'Server:' header
# of the HTTP response.
Expand Down
15 changes: 13 additions & 2 deletions core/base/src/TObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -913,14 +913,25 @@ void TObject::Streamer(TBuffer &R__b)
}
} else {
R__b.WriteVersion(TObject::IsA());
// Can not read TFile.h here and avoid going through the interpreter by
// simply hard-coding this value.
// This **must** be equal to TFile::k630forwardCompatibility
constexpr int TFile__k630forwardCompatibility = BIT(2);
const auto parent = R__b.GetParent();
if (!TestBit(kIsReferenced)) {
R__b << fUniqueID;
R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
if (R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
R__b << fBits;
else
R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
} else {
//if the object is referenced, we must save its address/file_pid
UInt_t uid = fUniqueID & 0xffffff;
R__b << uid;
R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
if (R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
R__b << fBits;
else
R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
TProcessID *pid = TProcessID::GetProcessWithUID(fUniqueID,this);
//add uid to the TRefTable if there is one
TRefTable *table = TRefTable::GetRefTable();
Expand Down
7 changes: 7 additions & 0 deletions io/io/inc/TFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ class TFile : public TDirectoryFile {
public:
/// TFile status bits. BIT(13) is taken up by TObject
enum EStatusBits {
// Produce files forward compatible with (unpatched) version older than
// v6.30 by recording the internal bits kIsOnHeap and kNotDeleted; Older
// releases were not explicitly setting those bits to the correct value
// but instead used verbatim the value stored in the file.
pcanal marked this conversation as resolved.
Show resolved Hide resolved
// Note that to avoid a circular dependency, this value is used
// hard coded in TObject.cxx.
k630forwardCompatibility = BIT(2),
kRecovered = BIT(10),
kHasReferences = BIT(11),
kDevNull = BIT(12),
Expand Down
5 changes: 5 additions & 0 deletions io/io/src/TFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,11 @@ void TFile::Init(Bool_t create)
//*-* -------------attempt recovering the file
Bool_t tryrecover = (gEnv->GetValue("TFile.Recover", 1) == 1) ? kTRUE : kFALSE;

//*-* -------------Check if we need to enable forward compatible with version
//*-* -------------prior to v6.30
if (gEnv->GetValue("TFile.v630forwardCompatibility", 0) == 1)
SetBit(k630forwardCompatibility);

//*-* -------------Read keys of the top directory
if (fSeekKeys > fBEGIN && fEND <= size) {
//normal case. Recover only if file has no keys
Expand Down
7 changes: 6 additions & 1 deletion io/io/src/TStreamerInfoWriteBuffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,12 @@ Int_t TStreamerInfo::WriteBufferAux(TBuffer &b, const T &arr,

// special case for TObject::fBits in case of a referenced object
case TStreamerInfo::kBits: { DOLOOP {
UInt_t *x=(UInt_t*)(arr[k]+ioffset); b << (*x & (~kIsOnHeap & ~kNotDeleted));
UInt_t *x=(UInt_t*)(arr[k]+ioffset);
const auto parent = b.GetParent();
if (R__unlikely(parent && parent->TestBit(TFile::k630forwardCompatibility)))
b << *x;
else
b << (*x & (~kIsOnHeap & ~kNotDeleted));
if ((*x & kIsReferenced) != 0) {
TObject *obj = (TObject*)(arr[k]+eoffset);
TProcessID *pid = TProcessID::GetProcessWithUID(obj->GetUniqueID(),obj);
Expand Down
Loading