Access violation involving TThread (5.28)

I have a lot of data that needs to be crunched into several TTree files. To do this quickly, I have each core on my computer running a thread to analyze each file. This used to work under an older version, but after migrating to 5.28 I get access violation errors whenever I try to use trees within a TThread. Here is a test program I ran on a Windows 7 64bit machine with VC++9.

[code]//threadTreeTest.cpp
#include “TFile.h”
#include “TTree.h”
#include “TThread.h”

void testFunction(){
TThread::Printf(“Making root file”);
TFile *f=TFile::Open(“test.root”,“recreate”);
TThread::Printf(“Making tree”);
TTree *t=new TTree(“test”,“test”);
Int_t value=1;
TThread::Printf(“Making branch”);
t->Branch(“value”,&value,“value/I”);
TThread::Printf(“Filling tree”);
t->Fill();
TThread::Printf(“Writing tree”);
f->WriteTObject(t);
TThread::Printf(“Closing file”);
f->Close();
TThread::Printf(“Done”);
}

void threadTreeTest(){
TThread th=new TThread(“testThread”,(void()(void *))&testFunction);
th->Run();
}[/code]

[quote]>root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.28/00 14 December 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on win32)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L threadTreeTest.cpp+
Info in TWinNTSystem::ACLiC: creating shared library D:\Documents\Physics\Rese
arch\RDK\Code\tools\threadTreeTest_cpp.dll
2276066_cint.cxx
threadTreeTest_cpp_ACLiC_dict.cxx
Creating library D:\Documents\Physics\Research\RDK\Code\tools\threadTreeTest_
cpp.lib and object D:\Documents\Physics\Research\RDK\Code\tools\threadTreeTest_c
pp.exp
root [1] threadTreeTest()
root [2] Making root file
Making tree
Making branch[/quote]

[quote]Problem signature:
Problem Event Name: APPCRASH
Application Name: root.exe
Application Version: 0.0.0.0
Application Timestamp: 4d07c747
Fault Module Name: libCore.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4d079c90
Exception Code: c0000005
Exception Offset: 00072ce0
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789[/quote]
This is similar to an issue I had earlier with 5.22 that was resolved.
[url]Reading TFiles within thread (VC++9)
Like the previous time, the code will run using the -b flag, but that is not an acceptable long term solution in my case.

Hi Benjamin,

We are working on a solution. Stay tuned.

Cheers, Bertrand.