Skip to content

Commit

Permalink
fBits read: preserve kIsOnHeap, always set kNotDeleted. (#204)
Browse files Browse the repository at this point in the history
Rather than reading from the file the value of kIsOnHeap, preserve the value that was
calculated at object creation time (i.e. in the current execution).  For example, for
an embedded object (inside an object created on the heap or stack), the bit always
need to be off (i.e. it can never be explicitly deleted)

Co-authored-by: Philippe Canal <[email protected]>
  • Loading branch information
iarspider and pcanal authored Feb 14, 2024
1 parent c46ae6e commit 652680b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/base/src/TObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,9 @@ void TObject::Streamer(TBuffer &R__b)
if (R__b.IsReading()) {
R__b.SkipVersion(); // Version_t R__v = R__b.ReadVersion(); if (R__v) { }
R__b >> fUniqueID;
const UInt_t isonheap = fBits & kIsOnHeap; // Record how this instance was actually allocated.
R__b >> fBits;
fBits |= kIsOnHeap; // by definition de-serialized object is on heap
fBits |= isonheap | kNotDeleted; // by definition de-serialized object are not yet deleted.
if (TestBit(kIsReferenced)) {
//if the object is referenced, we must read its old address
//and store it in the ProcessID map in gROOT
Expand Down
2 changes: 2 additions & 0 deletions io/io/src/TStreamerInfoActions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ namespace TStreamerInfoActions
UInt_t *x = (UInt_t*)( ((char*)addr) + config->fOffset );
// Idea: Implement buf.ReadBasic/Primitive to avoid the return value
// Idea: This code really belongs inside TBuffer[File]
const UInt_t isonheap = *x & TObject::kIsOnHeap; // Record how this instance was actually allocated.
buf >> *x;
*x |= isonheap | TObject::kNotDeleted; // by definition de-serialized object are not yet deleted.

if ((*x & kIsReferenced) != 0) {
HandleReferencedTObject(buf,addr,config);
Expand Down
6 changes: 5 additions & 1 deletion io/io/src/TStreamerInfoReadBuffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ Int_t TStreamerInfo::ReadBufferConv(TBuffer &b, const T &arr, const TCompInfo *
DOLOOP {
UInt_t u;
b >> u;
u |= kNotDeleted; // by definition de-serialized object are not yet deleted.
if ((u & kIsReferenced) != 0) {
UShort_t pidf;
b >> pidf;
Expand Down Expand Up @@ -1019,7 +1020,10 @@ Int_t TStreamerInfo::ReadBuffer(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;
UInt_t *x=(UInt_t*)(arr[k]+ioffset);
const UInt_t isonheap = *x & TObject::kIsOnHeap; // Record how this instance was actually allocated.
b >> *x;
*x |= isonheap | TObject::kNotDeleted; // by definition de-serialized object are not yet deleted.
if ((*x & kIsReferenced) != 0) {
UShort_t pidf;
b >> pidf;
Expand Down

0 comments on commit 652680b

Please sign in to comment.