I got a problem with a TFile object during running my root application. The setup of my application looks like this:
got a main method which provide global data containing a TFile object
global data is protected with a TSemaphore
the main method starts two TTreads
a gui thread with a start and a stop button for the “work thread”
the work thread is running fine when I push the start button
but when I push the stop button, which just set a start/stop flag for the working thread in the global data. My working thread stops at points like TFile::Write() or TFile::Get(), which has nothing to do with my stop mechanic .
Now I try to create a example program to show you the error but this already stops when creating a new TFile?
[quote]Someone got an idea what I’m doing wrong?[/quote]Not really, this looks fine on the surface. What are the stack trace of where the thread unexpectedly stop?
I recommend you try running your example under gdb. I.e. if you start you example with./mycode 123 abcdogdb --args ./mycode 123 abc
gdb> run
.... segfault appears ...
gdb> where which (especially if you build your code with the -g option) would give you the line number where the crash happens. The stack trace you gave says that the crash happened in the routine:echo _ZN17TControlFunctions12SaveRootFileEv | c++filt
TControlFunctions::SaveRootFile()
Hi,
I rebuild my project a little bit, because I thought I had a problem in my program structure. Now my TFile object is created in the thread, which use it exclusive. No other thread is now using the object.
Now when I first start my program after a reboot of the system I get the segmentation violation below, when I start the program a second time it is running “fine”, except of my old problem.
[quote]Why are my attachments not added??[/quote]No sure, it might have a ‘dangerous’ extension or it might be too large. One way around both is to place your code on a web server (or on afs) where we can download it.
[quote]Do I handle the TFile object wrong?[/quote]No idea We would need to see your code. You might also see the problem by running your case under valgrind (see valgrind.org).
I took a older version of my program and add step by step the new parts until my current version.
The last version which work has the following construction:
parent thread which creates:
the working thread
and a thread for a text menu
Next step was to change the text menu by a GUI with the same functions (start/stop the working thread). Here occurs the problems which I described in my first posed.
I will throw out the code parts which are not necessary and post the code later today or tomorrow. And thanks for the valgrind hint, I will try it.
EDIT Code added.
in globalDef.h the different versions can be set on/off
the error occurs when using TControlFunctions::InitParamTable() without TFile::Write() works fine
with TControlFunctions::InitParamTable() it crashes when I want to stop the program EDIT
For me your example fails with:[quote]Error in TMySQLServer::TMySQLServer: Code: 2002 Msg: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
ERROR: Can not connect to the MySql server[/quote]
Please note the following C++ syntax errors:
TControlFunctions.h:43: error: extra qualification ‘TControlFunctions::’ on member ‘Init’
TControlFunctions.h:44: error: extra qualification ‘TControlFunctions::’ on member ‘SaveRootFile’
TControlFunctions.h:63: error: extra qualification ‘TControlFunctions::’ on member ‘InitRootFile’
TControlFunctions.h:64: error: extra qualification ‘TControlFunctions::’ on member ‘InitParamTable’
I was able to compile and run the code, but I fail to make it crash. Can you remind which exact setting I need to use and which exact step I need to take to get to the crash?
[quote]I try to install the new root version,[/quote]On which platform/compiler? Can you try the trunk?
Alternatively, if you do not need xrootd, disable it for now (configure … --disable-xrootd …)
I’m working with suse Linux 8.2 (can’t use a newer Linux because of company software which only works with the old kernel) and the GNU C++ compiler (3.3-23)
same failure with the trunk
was able to install root v5.27.06 with the option, but no effect same as before.