Error Reading Tree branch in QT

I am trying to execute following code in order to read a char string from a tree branch. The code works fine on CINT but same code when execute inside QT based interface generates a segment fault.

TFile f (“Test.root”);
TTree* dbTree = SynapseTree;
TBranch* bb = dbTree->GetBranch(“ConnectionName”);
int count =
char* n ="";
for (int j=0;j<count;j++){


Note that dbTree->Scan(“ConnectionName”) works fine.

Also inside the same QT GUI I am able to list the tree branches (Image attached).

The error is
*** Break *** segmentation violation
Generating stack trace…
0xb65e8dbf in TLeafC::ReadBasket(TBuffer&) + 0x1b from /Library/root/lib/
0xb65c720b in TBranch::ReadLeaves(TBuffer&) + 0x2f from /Library/root/lib/
0xb65c6395 in TBranch::GetEntry(long long, int) + 0x261 from /Library/root/lib/
0x080534ac in MainForm::databaseView_doubleClicked(QListViewItem*, QPoint const&, int) + 0x660 from ./neobase
0x08068ad2 in MainForm::qt_invoke(int, QUObject*) + 0x1ca from ./neobase
0xb58ab386 in QObject::activate_signal(QConnectionList*, QUObject*) + 0x13a from /Library/qt-x11-free-3.3.5/lib/
0xb5b91ea8 in QListView::doubleClicked(QListViewItem*, QPoint const&, int) + 0xb4 from /Library/qt-x11-free-3.3.5/lib/
0xb597442f in QListView::contentsMouseDoubleClickEvent(QMouseEvent*) + 0x13b from /Library/qt-x11-free-3.3.5/lib/
0xb599e53d in QScrollView::viewportMouseDoubleClickEvent(QMouseEvent*) + 0x89 from /Library/qt-x11-free-3.3.5/lib/ 0xb599de46 in QScrollView::eventFilter(QObject*, QEvent*) + 0xfa from /Library/qt-x11-free-3.3.5/lib/
0xb5972361 in QListView::eventFilter(QObject*, QEvent*) + 0x5d from /Library/qt-x11-free-3.3.5/lib/
0xb58a91b8 in QObject::activate_filters(QEvent*) + 0x68 from /Library/qt-x11-free-3.3.5/lib/
0xb58a9106 in QObject::event(QEvent*) + 0xa2 from /Library/qt-x11-free-3.3.5/lib/
0xb58d9576 in QWidget::event(QEvent*) + 0x22 from /Library/qt-x11-free-3.3.5/lib/
0xb585b235 in QApplication::internalNotify(QObject*, QEvent*) + 0xb5 from /Library/qt-x11-free-3.3.5/lib/
0xb585aa4d in QApplication::notify(QObject*, QEvent*) + 0x1a9 from /Library/qt-x11-free-3.3.5/lib/
0xb58005b7 in QETWidget::translateMouseEvent(_XEvent const*) + 0x997 from /Library/qt-x11-free-3.3.5/lib/
0xb57fe3d9 in QApplication::x11ProcessEvent(_XEvent*) + 0x45d from /Library/qt-x11-free-3.3.5/lib/
0xb5812e9e in QEventLoop::processEvents(unsigned) + 0x966 from /Library/qt-x11-free-3.3.5/lib/
0xb586ac13 in QEventLoop::enterLoop() + 0xe7 from /Library/qt-x11-free-3.3.5/lib/
0xb586aad0 in QEventLoop::exec() + 0x24 from /Library/qt-x11-free-3.3.5/lib/
0xb585b450 in QApplication::exec() + 0x20 from /Library/qt-x11-free-3.3.5/lib/
0x080513f6 in main + 0x8a from ./neobase
0xb5351768 in __libc_start_main + 0xf8 from /lib/tls/
0x080512e1 in TFile::TFile[in-charge](char const*, char const*, char const*, int) + 0x31 from ./neobase


Hi thank you for your report.
I’ll check it. Mean time can you specify the ROOT version you tried your example with.
Next time I would appreciate you file the formal ROOT Bug report also. … up=savroot

Thank you

char* n =""; bb->SetAddress(n);is incorrect! You are requesting ROOT to write into a const zero length array!. The fact that it does crash in CINT is simply part of the fact that the expected behavior in this case is random.
Instead you should use

char* n = new char[max_len]; bb->SetAddress(n);


thanks a lot. It works now