[ROOT] TThread::Printf() in TThread::Fun() prevents threads from running

From: Volker Hejny (V.Hejny@fz-juelich.de)
Date: Thu Feb 07 2002 - 17:06:10 MET


Hi,

by a lucky accident I observed the following behaviour of TThread:
With the status messages in TThread::Fun():
  sprintf(cbuf,"Thread %s.%ld is running",th->GetName(),th->fId);
  TThread::Printf("\n %s\n\n",cbuf);
and
  sprintf(cbuf,"Thread %s.%ld finished",th->GetName(),th->fId);
  TThread::Printf("\n %s\n\n",cbuf);
threads do not work. Actually they enter Printf() and
never return, so the thread state is kRunningState without
a running thread. When commenting out the TThread::Printf() lines
everything runs smoothly, fine and very stable! 

I commented out these lines in an early stage of development and
just found that on all other machines the final code does not run!

I'm using the actual CVS HEAD revision (3.03.00) and the situation
is reproducable on a debian installation (unstable, libc6 2.2.5) and 
a recent SuSE 7.3 (libc6 2.2.4). 

>From the main program, the following function is called:

Int_t IpcServer::Start() {
  if (fsThread != 0) return 0;
  
  fsServerSocket = new TServerSocket(0);
  if (!fsServerSocket->IsValid()) { 
     gLog(CLog::kError) << "Could not install IpcServer" << std::endl;
     delete fsServerSocket;
     fsServerSocket = 0;
     return 0;
  }
								 
  fsPort = fsServerSocket->GetLocalPort();  

  gLog(CLog::kMessage) << "IpcServer: Listening on port " 
		       << fsPort << std::endl;
			       
  fsThread = new TThread("Main",IpcServer::Accept, (void*) 0);
  fsThread->Run();
  return fsPort;
}

After fsThread->Run() GetState() returns kRunningState, but the
function IpcServer::Accept is never entered.

Best regards,
Volker

-- 
Dr. Volker Hejny                Tel: 02461/616853                      ** 
Institut f. Kernphysik          Fax: 02461/613930                     **
---------------------------------------------------------------- **  ** ---  
Forschungszentrum Juelich GmbH, D-52425 Juelich                    **



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET