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

TTree: Creating a branch with std::vector can raise an internal error when mixing I/O systems. #10240

Open
1 task done
fweig opened this issue Mar 25, 2022 · 4 comments
Open
1 task done
Assignees

Comments

@fweig
Copy link

fweig commented Mar 25, 2022

  • Checked for duplicates

Describe the bug

Creating a branch in TTree with type std::vector<A> raises an internal error in ROOT, when class A inherits from a class that uses the old I/O system.

Expected behavior

Branch should be created successfully (I don't know if this behavior is supposed to be supported) or ROOT should abort with a more descriptive error message.

To Reproduce

Compile and run the following macro with root -l -b -q T.C+:

#include <vector>
#include "TTree.h"

#pragma link C++ class A;
#pragma link C++ class B+;
#pragma link C++ class std::vector<B>+;

struct A {
    int x;
    ClassDef(A, 1);
};
ClassImp(A);

struct B : A {
    int y;
    ClassDef(B, 1);
};
ClassImp(B);

void T() {
   TTree* tree = new TTree("T", "T");
   std::vector<B> bvec;
   tree->Branch("B", &bvec);
}

Macro aborts with the error:
Fatal in <TBranchElement::InitializeOffsets>: Could not find the real data member 'B' when constructing the branch 'B' [Likely an internal error, please report to the developers].

Setup

  1. ROOT version: 6.22.08 (built myself), 6.26.00 (binary download)
  2. Operating System: Ubuntu 18.04

Additional context

None.

@fweig fweig added the bug label Mar 25, 2022
@fweig fweig changed the title TTree: Creating a branch with std::vector can raise an internal error. TTree: Creating a branch with std::vector can raise an internal error when mixing I/O systems. Mar 25, 2022
@pcanal
Copy link
Member

pcanal commented Mar 27, 2022

Did you intentionally used:

#pragma link C++ class A;

instead of

#pragma link C++ class A+;

?

@fweig
Copy link
Author

fweig commented Mar 27, 2022

Yes, that's the bug. The second variant should work fine.

@pcanal
Copy link
Member

pcanal commented Mar 29, 2022

This is indeed a problem but should be a rare occurrence as the 'without the +' case has a lot of disadvantage.

Out of curiosity, what lead you to use that form?

@fweig
Copy link
Author

fweig commented Mar 29, 2022

I discovered this by accident when working on CbmRoot. Basically I created a branch with the setup from the reproducer and was greeted with that error message. The base class in that case is pretty old code. I assume nobody ever bothered to update the link def and that's why the '+' was missing in the first place. However it took me some time to figure out that this was the problem and caused quite a bit of headache. That's why I wrote it would be nice if Root would abort with a better error message here. Becomes trivial to fix then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants