RefineSensorModel Segfault
Mantis Issue 1022, reported by jinglada, assigned to rkanavath, created: 2015-04-03
The RefineSensorModel crashes due to SensorModelAdapter failing to cast the m_SensorModel (with type ossimProjection*) into an ossimSensorModel* in the WriteGeomFile method.
sensorModel = dynamic_cast<ossimSensorModel *>(m_SensorModel);
produces a null pointer (which by the way, is not checked!).
(gdb) r Starting program: /home/inglada/OTB/builds/OTB/bin/otbApplicationLauncherCommandLine RefineSensorModel /home/inglada/OTB/builds/OTB/bin -ingeom PbRefineSensorModel/Im2/s1a-iw-grd-vh-20150210t060009-20150210t060034-004557-0059a3-002.geom -outgeom /tmp/tt.geom -inpoints PbRefineSensorModel/Im1/pts_idV5.txt [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
2015 Apr 03 19:03:43 : Application.logger (INFO) Elevation management: setting default height above ellipsoid to 0 meters 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=10683.2, y=14610.3, z=0, lon=1.44079, lat=43.5991 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=10765.4, y=14634.6, z=0, lon=1.43561, lat=43.5922 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=11014, y=14631.2, z=0, lon=1.43164, lat=43.57 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=10673.7, y=14172.7, z=0, lon=1.49417, lat=43.5934 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=10330.6, y=15442.5, z=0, lon=1.34683, lat=43.6435 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=10566.8, y=15190.8, z=0, lon=1.37265, lat=43.6187 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=8347.1, y=13042.1, z=0, lon=1.68363, lat=43.785 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=7064.78, y=16473.3, z=0, lon=1.28953, lat=43.9525 2015 Apr 03 19:03:43 : Application.logger (INFO) Adding tie point x=13067.2, y=14057.6, z=0, lon=1.45705, lat=43.377 2015 Apr 03 19:03:43 : Application.logger (INFO) Optimization in progress ... 2015 Apr 03 19:03:43 : Application.logger (INFO) Done.
Program received signal SIGSEGV, Segmentation fault. 0x00007ffff3ba43af in otb::SensorModelAdapter::WriteGeomFile (this=0xb65720, outfile=...) at /home/inglada/OTB/OTB/Code/UtilitiesAdapters/OssimAdapters/otbSensorModelAdapter.cxx:244 244 bool success = sensorModel->saveState(geom); (gdb) p geom $1 = { = {_vptr.ossimErrorStatusInterface = 0x7fffe7f50670, theErrorStatus = 0, static RTTI_obj = {n = 0x611a50 "ossimErrorStatusInterface", b = 0x7fffe8012dd8, ns = 5, subtypes = 0x614f60, static null_type = {n = 0x612b00 "NULL", b = 0x7fffe8013938, ns = 0, subtypes = 0x0, static null_type = , new_obj = 0, cast = 0}, new_obj = 0, cast = 0x7fffe731680c <ossimErrorStatusInterface::RTTI_scast(int, void*)>}}, = {_vptr.ossimReferenced = 0x7fffe7f50710, theRefMutex = 0xb25470, theRefCount = 0}, static NULL_KW = {static npos = , _M_dataplus = {<std::allocator> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x7fffe5818498 "}}, m_map = {_M_t = { _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, std::basic_string<char, std::char_traits, std::allocator > > > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, std::basic_string<char, std::char_traits, std::allocator > > > >> = {}, }, _M_key_compare = {<std::binary_function<std::basic_string<char, std::char_traits, std::allocator >, std::basic_string<char, std::char_traits, std::allocator >, bool>> = {}, }, _M_header = {_M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x7fffffffca40, _M_right = 0x7fffffffca40}, _M_node_count = 0}}}, m_delimiter = 58 ':', m_preserveKeyValues = true, m_expandEnvVars = false} (gdb) p sensorModel $2 = (ossimSensorModel *) 0x0
1430217430 - cpalmannDear Jordi,
from your .geom file, I can see that the type is set to ossimRpcProjection. The ossimRpcProjection class inherits from ossimRpcProjection (as does ossimSensorModel), but not from ossimSensorModel (see http://trac.osgeo.org/ossim/browser/trunk/ossim/include/ossim/projection/ossimRpcProjection.h).
The dynamic cast can't be fine, OTB just takes into account the ossimSensorModel case. I added messages to check the null pointers.
Would you allow the OTB team to put these data to the OTB-Data rep, so that new tests would be performed ?
1430223669 - ingladaNo problem with adding the data to OTB-Data
1430234652 - cpalmannI added the needed modifications to otbSensorModelAdapter.cxx, as well as a second test with the data provided by Jordi (thanks !).
Now, this class can deal with ossimSensorModel (in priority) and ossimRpcProjection.