[Insight-developers] interrupting filter execution

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Jul 19 09:39:43 EDT 2006


I think so too. Each thread has its own stack; so it should have its own
exception stack too. So re-throwing it to the caller would be valid only
within the thread.

There must be some place where you do say 
   gaussianFilter->Update();

Could you not add the try/catch block there ? The gaussian filter runs
as a single threaded filter.

--

Also every subfilter's update in a filter that uses a mini-pipeline
should be within such a try catch block, should it not ?

BigFilter::GenerateData()
{
 try { filter1->Update() } catch (ProgressAborted & e) { // Reset
pipeline etc }
 try { filter2->Update() } catch (ProgressAborted & e) { // Reset
pipeline etc }
}

Thanks
-karthik

On Tue, 2006-07-18 at 17:31 -0600, Paul Koshevoy wrote:
> For some reason, I can't catch the exception thrown in ProgressAccumulator.
> 
> I've modified the ProgressAccumulator::ReportProgress as follows:
>   if( m_MiniPipelineFilter->GetAbortGenerateData() )
>     {
>     throw ExceptionObject();
>     }
> 
> 
> It crashes with the following stack trace:
> 
> FIXME: ABORT: DiscreteGaussianImageFilter
> terminate called after throwing an instance of 'itk::ExceptionObject'
>   what():  Unknown:0:
> None
> 
> Program received signal SIGABRT, Aborted.
> [Switching to Thread 1077832032 (LWP 27676)]
> 0x00002aaaacf8b43a in raise () from /lib64/tls/libc.so.6
> (gdb) where 27
> #0  0x00002aaaacf8b43a in raise () from /lib64/tls/libc.so.6
> #1  0x00002aaaacf8c870 in abort () from /lib64/tls/libc.so.6
> #2  0x00002aaaacbb68b0 in __gnu_cxx::__verbose_terminate_handler ()
>    from /usr/lib64/libstdc++.so.6
> #3  0x00002aaaacbb48e6 in __gxx_personality_v0 ()
>    from /usr/lib64/libstdc++.so.6
> #4  0x00002aaaacbb48bd in __gxx_personality_v0 ()
>    from /usr/lib64/libstdc++.so.6
> #5  0x00002aaaace58848 in _Unwind_ForcedUnwind () from /lib64/libgcc_s.so.1
> #6  0x00002aaaace5892b in _Unwind_Resume () from /lib64/libgcc_s.so.1
> #7  0x000000000062ab11 in itk::ProcessObject::UpdateProgress ()
> #8  0x000000000044c569 in
> itk::NeighborhoodOperatorImageFilter<itk::Image<float, 2u>,
> itk::Image<float, 2u>, double>::ThreadedGenerateData (this=0x8670b54,
>     outputRegionForThread=@0x403e43a0, threadId=1077821840)
>     at
> /usr/sci/crcns-data1/InsightToolkit-2.4.1/Code/BasicFilters/itkNeighborhoodOperatorImageFilter.txx:136
> #9  0x00000000004332a1 in itk::ImageSource<itk::Image<float, 2u>
> >::ThreaderCallback (arg=0x6c16)
>     at
> /usr/sci/crcns-data1/InsightToolkit-2.4.1/Code/Common/itkImageSource.txx:273
> #10 0x00000000006222ea in itk::MultiThreader::SingleMethodExecute ()
> #11 0x00000000004331e4 in itk::ImageSource<itk::Image<float, 2u>
> >::GenerateData (this=0xf66770)
>     at
> /usr/sci/crcns-data1/InsightToolkit-2.4.1/Code/Common/itkImageSource.txx:229
> #12 0x000000000062ce5a in itk::ProcessObject::UpdateOutputData ()
> #13 0x000000000062cf3c in itk::ProcessObject::UpdateOutputData ()
> #14 0x000000000044667c in itk::StreamingImageFilter<itk::Image<float,
> 2u>, itk::Image<float, 2u> >::UpdateOutputData (this=0xf67010)
>     at
> /usr/sci/crcns-data1/InsightToolkit-2.4.1/Code/BasicFilters/itkStreamingImageFilter.txx:159
> #15 0x0000000000444a2c in
> itk::DiscreteGaussianImageFilter<itk::Image<float, 2u>,
> itk::Image<float, 2u> >::GenerateData (this=0x6c16)
>     at
> /usr/sci/crcns-data1/InsightToolkit-2.4.1/Code/BasicFilters/itkDiscreteGaussianImageFilter.txx:306
> #16 0x000000000062ce5a in itk::ProcessObject::UpdateOutputData ()
> #17 0x0000000000423e85 in smooth<itk::Image<float, 2u> > (in=0x403e5810,
>     sigma=7.3376495356751903e-317, maximum_error=0.10000000000000001)
>     at common.hxx:987
> #18 0x0000000000424ab6 in shrink<itk::Image<unsigned char, 2u> >
> (in=0x6c1c,
>     shrink_factor=@0xe29ca0, maximum_error=0.10000000000000001)
>     at common.hxx:1006
> #19 0x0000000000424d63 in std_tile<itk::Image<unsigned char, 2u> > (
>     fn_image=0x6c1c <Address 0x6c1c out of bounds>,
> shrink_factor=@0xe29ca0,
>     pixel_spacing=@0xcd74d0, blab=6) at common.hxx:3596
> #20 0x000000000042a114 in ImageLoader::load_mosaic<itk::Image<unsigned
> char, 2u> > (this=0xe29ca0, fn_mosaic=0x0, shrink_factor=@0x403e60a0,
>     mosaic=@0x403e6090, mosaic_mask=@0x42a114) at ImageLoaderDialog.h:119
> #21 0x0000000000413499 in ImageLoader::run (this=0xe29c80)
>     at ImageLoaderDialog.cpp:81
> #22 0x00002aaaac53e833 in QThreadPrivate::start ()
>    from /usr/lib64/libQtCore.so.4
> #23 0x00002aaaac8e8fa5 in start_thread () from /lib64/tls/libpthread.so.0
> #24 0x00002aaaad019cb2 in clone () from /lib64/tls/libc.so.6
> #25 0x0000000000000000 in ?? ()
> #26 0x0000000000000000 in ?? ()
> (More stack frames follow...)
> 
> My guess is I can't catch the exception because it was thrown from a
> different thread than the one that has the try/catch block.
> I have the following try/catch block (it can be seen as frame #20 in the
> stack trace):
> 
>     try
>     {
>       if (load_mosaic<native_image_t>(qPrintable(source_),
>                       shrink_factor_,
>                       mosaic,
>                       mask))
>       {
>     data_ready_ = true;
>     emit statusUpdate(tr("Done "));
>       }
>       else
>       {
>     emit statusUpdate(tr("Aborted "));
>       }
>     }
>     catch (itk::ExceptionObject & exception)
>     {
>       emit statusUpdate(tr(exception.GetDescription()));
>     }
>     catch (...)
>     {
>       emit statusUpdate(tr("FIXME: caught an unrecognized exception"));
>     }
> 
> 
> Karthik Krishnan wrote:
> > Never mind.. I am stupid. Discard the earlier suggestion. The
> > exception must be thrown by the filter, of course.., not you.
> >
> > That exception is also thrown by the filter or the progress reporter
> > in the CompletedPixel method.
> > http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkProgressReporter.cxx?rev=1.8&root=Insight&view=markup
> >
> >
> > It should likewise be thrown also in the
> > ProgressAccumulator.cxx::ReportProgress method as in
> > if (m_MiniPipelineFilter->GetAbortGenerateData())
> >  {
> >   throw ProgressAborted();
> >  }
> >
> > That addition should fix it, I suppose. Could you check ?
> >
> > Thanks
> > -karthik
> >
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list