GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Bugs, Fixes, Releases » FinishTask() funktion for uninitialized Tasks -> Bug or feature?
FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20145] Wed, 18 January 2017 15:29 Go to next message
Dominik Steinschaden is currently offline  Dominik Steinschaden
Messages: 28
Registered: April 2015
continuous participant
From: *smi.oeaw.ac.at
Hello,

Currently I'm programming a few new Classes/ Tasks for PandaRoot, and realized the following behavior.

In my "Init()" function I implemented some checks and if they fail a "kERROR" is returned. (mainly if the needed input Branches are not found)
As expected for this "uninitialized" Tasks the "Task::Exec()" is not processes subsequently.
BUT the Task::FinishTask() function is still called, which leads to a segmentation violation in my case, although this is exactly what I want to avoid by doing this checks during the initialization.

Is this working as expected?

regards Dominik
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20148 is a reply to message #20145] Wed, 18 January 2017 15:35 Go to previous messageGo to next message
Ralf Kliemt is currently offline  Ralf Kliemt
Messages: 507
Registered: May 2007
Location: GSI, Darmstadt
first-grade participant

From: *gsi.de
Hi Dominik,

Although I'm no expert I think this behavior is ok. You want to have the possibility to remove the traces of your Task even if the initialization fails. In principal you can re-initialize correctly after the change of the run.

There is a FairSoft part on the GSI forums, so the question should be asked there, too.

Cheers!
Ralf
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20152 is a reply to message #20148] Wed, 18 January 2017 15:42 Go to previous messageGo to next message
Dominik Steinschaden is currently offline  Dominik Steinschaden
Messages: 28
Registered: April 2015
continuous participant
From: *smi.oeaw.ac.at
ok I see that there is maybe sometimes a point in having the finishTask called even in such a case, ok.

so thanks for the answer.

I will just rearrange my Init() function. My plan was to first do the checks and if everything goes fine then all needed variables are initialized. therefore if the checks fail, the variables are not initialized for the finishTask()

Just wanted to save resources . . .
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20154 is a reply to message #20148] Wed, 18 January 2017 15:46 Go to previous messageGo to next message
Radoslaw Karabowicz is currently offline  Radoslaw Karabowicz
Messages: 108
Registered: June 2004
Location: GSI
continuous participant
From: *gsi.de
Hi Dominik,

There is also a FairTask::Finish() method, that is only called if the task is initialized...

yours
radek
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20155 is a reply to message #20154] Wed, 18 January 2017 16:05 Go to previous messageGo to next message
Radoslaw Karabowicz is currently offline  Radoslaw Karabowicz
Messages: 108
Registered: June 2004
Location: GSI
continuous participant
From: *gsi.de
Or, to make it even better, just check in your FinishTask() for the IsActive() flag.
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20159 is a reply to message #20152] Wed, 18 January 2017 16:27 Go to previous messageGo to next message
Tobias Stockmanns is currently offline  Tobias Stockmanns
Messages: 489
Registered: May 2007
first-grade participant
From: *netcologne.de
Hi Dominik,

I do not know your code but it would be very easy either to save the output of Init() in a variable and put the FinishTask() part in an if-statement or have your pointers initialized to 0 (as you always should do) and check for that in your FinishTask().

Cheers,

Tobias
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20162 is a reply to message #20152] Wed, 18 January 2017 16:51 Go to previous messageGo to next message
StefanoSpataro is currently offline  StefanoSpataro
Messages: 2736
Registered: June 2005
Location: Torino
first-grade participant

From: *to.infn.it
Hi,
a good praxis (or maybe THE praxis) is to initialize the variables in the constructor, and not in the Init function:

PndStuff::PndStuff() : PndFather(), a(0), b(0), object() {}


In this way also the compiler helps you to find what is missing. Variables should be never left uninitialized. Once you have them initialized, in the Init you can set the proper values, or leave them as they are, and you won't have problems in the FinishTask.
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20167 is a reply to message #20162] Thu, 19 January 2017 10:42 Go to previous messageGo to next message
Dominik Steinschaden is currently offline  Dominik Steinschaden
Messages: 28
Registered: April 2015
continuous participant
From: *smi.oeaw.ac.at
Thanks for the help.

Just for interested persons: the variable causing the problems was a pointer to a TClonesArray which is used to write the data into the outputfile.


InitStatus PndSuperTask::Init(){
....

FairRootManager* ioman = FairRootManager::Instance();

fOutArray = ioman->Register(fOutBranchName.Data(), "FairTimeStamp", "EventDetermination", fPersistence);

.....

And If no Output is generated I want to avoid to register an output branch. I will just use an additional If statement in the FinishTask() as suggested.

Dominik
Re: FinishTask() funktion for uninitialized Tasks -> Bug or feature? [message #20172 is a reply to message #20167] Thu, 19 January 2017 12:24 Go to previous message
StefanoSpataro is currently offline  StefanoSpataro
Messages: 2736
Registered: June 2005
Location: Torino
first-grade participant

From: *to.infn.it
But in PndSupertask costructor did you put something like

PndSuperTask::PndSuperTask : xxx, xxx, xxx,  fOutArray(), xxx, xxxx 


?
Previous Topic: PandaRoot Feb17
Next Topic: Preparations Release 02/17
Goto Forum:
  


Current Time: Thu Mar 28 19:59:46 CET 2024

Total time taken to generate the page: 0.01284 seconds