Viewer manager segfault when trying to display complex composition with 1 band image
Mantis Issue 87, reported by echristophe, assigned to jmichel, created: 2009-02-06
Step to reproduce:
- open single band image
- go to viewer setup
- choose complex composition => segfault
The following access it not controlled:
OTB/Code/Visu/otbImageViewerBase.txx:124 124 double im = static_cast(pixel[m_GreenChannelIndex])
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fb035353770 (LWP 1561)] 0x0000000000512cca in otb::ImageViewerBase<double, double>::ComputeNormalizationFactors (this=0x18201d0) at /home/christop/OTB/trunk/OTB/Code/Visu/otbImageViewerBase.txx:124 124 double im = static_cast(pixel[m_GreenChannelIndex]); (gdb) bt #0 0x0000000000512cca in otb::ImageViewerBase<double, double>::ComputeNormalizationFactors (this=0x18201d0) at /home/christop/OTB/trunk/OTB/Code/Visu/otbImageViewerBase.txx:124 #1 (closed) 0x00000000004b5f9a in otb::ImageViewerBase<double, double>::SetViewModel (this=0x18201d0, viewModel=otb::ImageWidgetBase::COMPLEX_MODULUS) at /home/christop/OTB/trunk/OTB/Code/Visu/otbImageViewerBase.txx:1155 #2 (closed) 0x00000000004c5984 in otb::ImageViewerManager::ViewerSetupOk (this=0x180bc20) at /home/christop/OTB/trunk/OTB-Applications/ViewerManager/otbImageViewerManager.txx:657 #3 (closed) 0x0000000000517b5e in ImageViewerManagerGUI::cb_guiViewerSetupOk_i (this=0x180bd08) at /home/christop/OTB/OTB-Binary-Applications-Debug/ViewerManager/otbImageViewerManagerGUI.cxx:90 #4 (closed) 0x0000000000517b91 in ImageViewerManagerGUI::cb_guiViewerSetupOk (o=0x1812120, v=0x0) at /home/christop/OTB/OTB-Binary-Applications-Debug/ViewerManager/otbImageViewerManagerGUI.cxx:93 #5 (closed) 0x000000000051b23e in Fl_Widget::do_callback (this=0x1812120) at /usr/include/FL/Fl_Widget.H:187 #6 (closed) 0x00007fb030a71594 in Fl_Button::handle () from /usr/bin/../lib/libfltk.so.1.1 #7 (closed) 0x00007fb030a6a38e in ?? () from /usr/bin/../lib/libfltk.so.1.1 #8 (closed) 0x00007fb030a6b4bc in Fl::handle () from /usr/bin/../lib/libfltk.so.1.1 #9 (closed) 0x00007fb030ab2897 in fl_handle () from /usr/bin/../lib/libfltk.so.1.1 #10 (closed) 0x00007fb030ab3b24 in ?? () from /usr/bin/../lib/libfltk.so.1.1 #11 (closed) 0x00007fb030ab4374 in fl_wait () from /usr/bin/../lib/libfltk.so.1.1 #12 (closed) 0x00007fb030a6bf58 in Fl::wait () from /usr/bin/../lib/libfltk.so.1.1 #13 (closed) 0x00007fb030a6c07d in Fl::run () from /usr/bin/../lib/libfltk.so.1.1 #14 (closed) 0x000000000047f388 in main (argc=4, argv=0x7fff3d52c548) at /home/christop/OTB/trunk/OTB-Applications/ViewerManager/otbImageViewerManager.cxx:44
1233930896 - julienThis also occurs when selecting RGB composition mode, except the ViewerManager does not crash but returns with an uncaught exception. The fields to select channels in the viewer setup interface are left blank in both cases.
The fix should both control and throw exception before accessing to data in otb::ViewerBase, and fill the fields with possible value and catch possible exception in the ViewerManager.
1233937159 - julienAdded more control and exceptions in otbImageViewerBase.txx and otbImageWidgetBase.txx: http://hg.orfeo-toolbox.org/OTB/rev/e8797595d5f6
Added automatic fill of the channel fields with available values in otbImageViewerManager as well as fl_alert exception reporting in case the user forces wrong channel indices: http://hg.orfeo-toolbox.org/OTB-Applications/rev/03f8f0b1091a
1234175745 - julienFixed.