Hi Brad,

It was a combination of factors. I recursively called a function when the 
exception was called. This after some time resulted in a stack overflow. In 
debug mode using VS2008 I was able to debug much further when the explicit 
catch to itk::ExceptionObject was there. Without it it said "There is no source 
code available for the current location." from which I concluded there was 
something wrong with catch(...).
Anyway the solution is not in changing the ITK ProcessObject, but in 
circumventing the stack overflow. The debug differences between the two codes I 
cannot explain.

Thanks for your advice,
Marius

From: [email protected] 
[mailto:[email protected]] On Behalf Of [email protected]
Sent: dinsdag 29 mei 2012 15:15
To: [email protected]
Cc: [email protected]
Subject: Re: [Insight-developers] changes to ProcessObject

Hi Brad,

Ah, it is good to know that the throw without arguments still keeps its type. 
It's just that I added these lines back and then my program worked again. But 
the relevant code is a bit scattered around my toolkit, so debugging is a bit 
complicated. Let me debug somewhat further, maybe it is a combination of 
factors.

Thanks, Marius

From: Bradley Lowekamp 
[mailto:[email protected]]<mailto:[mailto:[email protected]]>
Sent: dinsdag 29 mei 2012 15:02
To: Staring, M. (LKEB)
Cc: [email protected]<mailto:[email protected]>
Subject: Re: [Insight-developers] changes to ProcessObject

Hello Marius,


The following code:

#include <iostream>

int main( void )
{
  try
    {
    try
      {
      throw 999;
      }
    catch ( ... )
      {
      std::cerr << "Rethrowing ellipsis exception!" << std::endl;
      throw;
      }
    }
  catch ( int n )
    {
    std::cerr << "Caught an integer: " << n << std::endl;
    return EXIT_SUCCESS;
    }

  std::cerr << "Failed to catch exception." << std::endl;
  return EXIT_FAILURE;
}


Will catch and rethrow any exception as the same type it catches, so the code 
in ProcessObject should do what you wish.

What are you seeing to indicate that that you don't think that this is working?

Brad





On May 29, 2012, at 8:35 AM, [email protected]<mailto:[email protected]> wrote:

Hi all, Gaetan,

This commit:

http://itk.org/gitweb?p=ITK.git;a=commitdiff;h=322cb3952a45cbdb4a100a3d308769a6027d4f95

changed the function ProcessObject::UpdateOutputData. Notably a try-catch was 
changed from

try
      {
      this->GenerateData();
      }
    catch( ProcessAborted & excp )
      {
      this->InvokeEvent( AbortEvent() );
      this->ResetPipeline();
      this->RestoreInputReleaseDataFlags();
      throw excp;
      }
    catch( ExceptionObject& excp )
      {
      this->ResetPipeline();
     this->RestoreInputReleaseDataFlags();
      throw excp;
      }

to

try
    {
    this->GenerateData();
    }
  catch ( ProcessAborted & excp )
    {
    this->InvokeEvent( AbortEvent() );
    this->ResetPipeline();
    this->RestoreInputReleaseDataFlags();
    throw excp;
    }
  catch (...)
    {
    this->ResetPipeline();
    this->RestoreInputReleaseDataFlags();
    throw;
    }

So itk::ExceptionObject is not explicitely caught anymore.

In my code I depend on itk::ExceptionObject to be caught and re-thrown. I catch 
it again higher up, and do something with it (not just stopping the program). 
With this change the original throw (itkExceptionMacro) ends up in catch(...) 
and just "throw" is called instead of "throw excp". Is it possible to add an 
extra catch:

try
    {
    this->GenerateData();
    }
  catch ( ProcessAborted & excp )
    {
    this->InvokeEvent( AbortEvent() );
    this->ResetPipeline();
    this->RestoreInputReleaseDataFlags();
    throw excp;
    }
  catch( ExceptionObject & excp )
    {
    this->ResetPipeline();
    this->RestoreInputReleaseDataFlags();
    throw excp;
    }
  catch (...)
    {
    this->ResetPipeline();
    this->RestoreInputReleaseDataFlags();
    throw;
    }

?

which would restore the original working of my code.

Regards, Marius

Marius Staring, PhD
Division of Image Processing (LKEB)
Department of Radiology
Leiden University Medical Center
PO Box 9600, 2300 RC Leiden, The Netherlands
phone: +31 (0)71 526 2137, fax: +31 (0)71 524 8256
[email protected]<mailto:[email protected]>

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers


========================================================

Bradley Lowekamp

Medical Science and Computing for

Office of High Performance Computing and Communications

National Library of Medicine

[email protected]<mailto:[email protected]>



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers

Reply via email to