[Insight-developers] better error message for exceptions in ThreadedGenerateData()

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 27 10:55:01 EDT 2007


Hi Gaetan,

Yes, the patch that you suggested was committed with
a couple of minor modifications.

If you have a chance, it will be great to test it in
the context of the original problem that you reported.



    Thanks


       Luis


-------------------
Gaëtan Lehmann wrote:
> 
> Hi Luis,
> 
> I was looking at that problem, and noticed that you have commited a  fix 
> already.
> 
> Thank you !
> 
> Gaëtan
> 
> 
> Le 13 sept. 07 à 14:41, Luis Ibanez a écrit :
> 
>>
>> Hi Gaetan,
>>
>>
>>          This patch is certainly a good idea.
>>
>>
>> The current message is pretty much useless, since it doesn't
>> tell us what the real problem was.
>>
>>
>> I have two concerns with the patch:
>>
>>
>> A) The description of the exception error is being passed to a
>>    "const char * details;" that is declared outside the try{}.
>>
>>    I'm under the impression that the exception object only
>>    exists inside the scope of the catch block. Therefore by the
>>    time the catch block finishes the exception object will
>>    be destroyed leaving the "details" pointer as a dangling
>>    pointer, that we shouldn't use for throwing an exception
>>    with an extended message.
>>
>>    We probably should make it a std::string instead...
>>
>>
>>
>> B) Adding a "catch( std::exception )" after a "catch(...)" will
>>    not have any effect, since the catch(...) will take care of
>>    any exception. We probably should put it before the catch-all
>>    "catch(...)".
>>
>>
>>
>> Does that make sense ?
>>
>>
>>
>> One way or the other, I agree that we should fix this,
>> We have had many frustrating encounters with the same
>> error message that just tell than an exception happened
>> but don't give any details of the original problem.
>>
>>
>>
>>     Thanks
>>
>>
>>       Luis
>>
>>
>> -----------------------
>> Gaëtan Lehmann wrote:
>>
>>> Hi,
>>> I'm debuging some threaded code currently, and I found the error   
>>> report really non-informative. Something like
>>> Progress  | 0 | 0.3 | 0.3 | 0.6terminate called after throwing an   
>>> instance of 'itk::ExceptionObject'
>>>   what():  /home/glehmann/src/Insight/Code/Common/  
>>> itkMultiThreader.cxx:405:
>>> itk::ERROR: MultiThreader(0x8176608): Exception occurred during   
>>> SingleMethodExecute
>>> I simply have no idea where the problem is, excepted that it may  be  
>>> in a threaded method. So I tried to modified the MultiTreader  code 
>>> to  return more information about what happened. The patch is  
>>> attached.  I'm now get something like
>>> Progress  | 0 | 0.3 | 0.3 | 0.6terminate called after throwing an   
>>> instance of 'itk::ExceptionObject'
>>>   what():  /home/glehmann/src/Insight/Code/Common/  
>>> itkMultiThreader.cxx:405:
>>> itk::ERROR: MultiThreader(0x8176608): Exception occurred during   
>>> SingleMethodExecute
>>> /home/glehmann/src/contrib-itk/binaryAttributeMorphology/  
>>> itkLabelPerimeterEstimationCalculator.h:83:
>>> itk::ERROR: LabelPerimeterEstimationCalculator(0x81c6928):  Unknown  
>>> label: 0
>>> Abandon
>>> Clearly, a better message to search for a bug :-)
>>> I'm not a thread expert, so maybe there is something wrong with  
>>> that  patch - any comment is welcome.
>>> Gaëtan
>>> -- 
>>> Gaëtan Lehmann
>>> Biologie du Développement et de la Reproduction
>>> INRA de Jouy-en-Josas (France)
>>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>>> http://voxel.jouy.inra.fr
>>> --------------------------------------------------------------------- 
>>> ---
>>> _______________________________________________
>>> Insight-developers mailing list
>>> Insight-developers at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-developers
> 
> 
> -- 
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr
> 
> 
> 


More information about the Insight-developers mailing list