Project

General

Profile

Bug #1466

Memory problem in datastructure?

Added by Rogers, Chris over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Data Structure
Target version:
Start date:
16 May 2014
Due date:
% Done:

100%

Estimated time:
Workflow:
New Issue

Description

I am getting a segmentation fault associated with valgrind output like:

Placing Tracker0.dat of type Cylinder position: (0,0,-2000) mm, rotationVector: (0,0,1) angle: 0 degrees, volume (incl daughters): 0.142 m^3,  material: He mass (excl daughters): 0.0236177 kg
Placing Tracker1.dat of type Cylinder position: (0,0,2000) mm, rotationVector: (0,0,1) angle: 0 degrees, volume (incl daughters): 0.142 m^3,  material: He mass (excl daughters): 0.0236177 kg
Setting the phase 
Made 0 attempts to phase 0 cavities with 0 remaining
.Traceback (most recent call last):
  File "/home/cr67/MAUS/maus_rogers_1376/src/common_py/ErrorHandler.py", line 160, in HandleCppException
    raise CppError(error_message)
ErrorHandler.CppError: Failed to recognise all json properties bzr_configuration bzr_revision bzr_status json_configuration maus_version start_of_job  at ObjectProcessor<ObjectType>::JsonToCpp
==10714== Invalid read of size 8
==10714==    at 0x9157950: MAUS::MCEvent::GetEMRHits() const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x940224E: MAUS::ObjectProcessorNS::PointerItem<MAUS::MCEvent, std::vector<MAUS::Hit<MAUS::EMRChannelId>, std::allocator<MAUS::Hit<MAUS::EMRChannelId> > > >::_SetJsonChild(MAUS::MCEvent const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x93FD45F: MAUS::ObjectProcessor<MAUS::MCEvent>::CppToJson(MAUS::MCEvent const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x94801BD: MAUS::PointerArrayProcessor<MAUS::MCEvent>::CppToJson(std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x9478D23: MAUS::ObjectProcessorNS::PointerItem<MAUS::Spill, std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > >::_SetJsonChild(MAUS::Spill const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x946E78F: MAUS::ObjectProcessor<MAUS::Spill>::CppToJson(MAUS::Spill const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x95769DE: MAUS::CppJsonSpillConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x15848FC2: MAUS::DataPyDictConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584C550: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==  Address 0x306d12d8 is 56 bytes inside a block of size 80 free'd
==10714==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==10714==    by 0x9164481: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x91645B8: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BE25: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BEE8: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x1584C570: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==    by 0x4F1FCE4: PyEval_EvalCodeEx (ceval.c:3253)
==10714==    by 0x4EA36E2: function_call (funcobject.c:526)
==10714==    by 0x4E7B7F2: PyObject_Call (abstract.c:2529)
==10714== 
==10714== Invalid read of size 8
==10714==    at 0x91578C0: MAUS::MCEvent::GetKLHits() const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x940BA0E: MAUS::ObjectProcessorNS::PointerItem<MAUS::MCEvent, std::vector<MAUS::Hit<MAUS::KLChannelId>, std::allocator<MAUS::Hit<MAUS::KLChannelId> > > >::_SetJsonChild(MAUS::MCEvent const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x93FD45F: MAUS::ObjectProcessor<MAUS::MCEvent>::CppToJson(MAUS::MCEvent const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x94801BD: MAUS::PointerArrayProcessor<MAUS::MCEvent>::CppToJson(std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x9478D23: MAUS::ObjectProcessorNS::PointerItem<MAUS::Spill, std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > >::_SetJsonChild(MAUS::Spill const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x946E78F: MAUS::ObjectProcessor<MAUS::Spill>::CppToJson(MAUS::Spill const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x95769DE: MAUS::CppJsonSpillConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x15848FC2: MAUS::DataPyDictConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584C550: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==  Address 0x306d12d0 is 48 bytes inside a block of size 80 free'd
==10714==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==10714==    by 0x9164481: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x91645B8: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BE25: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BEE8: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x1584C570: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==    by 0x4F1FCE4: PyEval_EvalCodeEx (ceval.c:3253)
==10714==    by 0x4EA36E2: function_call (funcobject.c:526)
==10714==    by 0x4E7B7F2: PyObject_Call (abstract.c:2529)
==10714== 
==10714== Invalid read of size 8
==10714==    at 0x9157A70: MAUS::MCEvent::GetPrimary() const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x94107EE: MAUS::ObjectProcessorNS::PointerItem<MAUS::MCEvent, MAUS::Primary>::_SetJsonChild(MAUS::MCEvent const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x93FD45F: MAUS::ObjectProcessor<MAUS::MCEvent>::CppToJson(MAUS::MCEvent const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x94801BD: MAUS::PointerArrayProcessor<MAUS::MCEvent>::CppToJson(std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x9478D23: MAUS::ObjectProcessorNS::PointerItem<MAUS::Spill, std::vector<MAUS::MCEvent*, std::allocator<MAUS::MCEvent*> > >::_SetJsonChild(MAUS::Spill const&, Json::Value&) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x946E78F: MAUS::ObjectProcessor<MAUS::Spill>::CppToJson(MAUS::Spill const&, std::string) (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x95769DE: MAUS::CppJsonSpillConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x15848FC2: MAUS::DataPyDictConverter::_convert(MAUS::Data const*) const (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584C550: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==  Address 0x306d12a8 is 8 bytes inside a block of size 80 free'd
==10714==    at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==10714==    by 0x9164481: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x91645B8: MAUS::Spill::~Spill() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BE25: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x916BEE8: MAUS::Data::~Data() (in /home/cr67/MAUS/maus_rogers_1376/build/libMausCpp.so)
==10714==    by 0x1584C570: _object* MAUS::PyObjectWrapper::unwrap<_object>(_object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x1584CE48: _object* MAUS::PyConverter::py_wrap<_object>(_object*, _object*) (in /home/cr67/MAUS/maus_rogers_1376/build/maus_cpp/converter.so)
==10714==    by 0x4F1E51C: PyEval_EvalFrameEx (ceval.c:4013)
==10714==    by 0x4F1EEE9: PyEval_EvalFrameEx (ceval.c:4099)
==10714==    by 0x4F1FCE4: PyEval_EvalCodeEx (ceval.c:3253)
==10714==    by 0x4EA36E2: function_call (funcobject.c:526)
==10714==    by 0x4E7B7F2: PyObject_Call (abstract.c:2529)
==10714== 
E
======================================================================
ERROR: test_process (__main__.MapCppTrackerMCDigitizationTestCase)
Test of the process function
----------------------------------------------------------------------
Traceback (most recent call last):
  File "src/map/MapCppTrackerMCDigitization/test_map_cpp_tracker_mc_digitization.py", line 91, in test_process
    maus_cpp.converter.json_repr(output_3)
ValueError: In branch mc_events
In branch primary
Failed to find branch primary: class data was NULL at PointerItem::GetCppChild

----------------------------------------------------------------------
Ran 2 tests in 296.047s

when running the MapCppTrackerMCDigitization test under the new API; most likely this is associated with some crapness in the datastructure.


Related issues

Related to MAUS - Feature #1376: JSON Conversion OverheadClosedRogers, Chris20 November 2013

Actions
#1

Updated by Rogers, Chris over 9 years ago

Printing the memory allocated during the unwrap, we have three copies of MAUS::Data (one owned by the caller, one return value and a temporary object). Printing out pointers, looks like mc_events vector is not being deep copied by Spill copy ctor... fix applied as part of #1376. Diff below:

=== modified file 'src/common_cpp/DataStructure/Spill.cc'
--- src/common_cpp/DataStructure/Spill.cc    2014-05-01 15:56:04 +0000
+++ src/common_cpp/DataStructure/Spill.cc    2014-05-16 12:55:38 +0000
@@ -63,6 +63,8 @@
         _mc = NULL;
     } else {
         _mc = new MCEventPArray(*md._mc);
+        for (size_t i = 0; i < _mc->size(); ++i)
+            _mc->at(i) = new MCEvent(*_mc->at(i)); 
     }

     if (_recon != NULL) {
@@ -75,6 +77,8 @@
         _recon = NULL;
     } else {
         _recon = new ReconEventPArray(*md._recon);
+        for (size_t i = 0; i < _recon->size(); ++i)
+            _recon->at(i) = new ReconEvent(*_recon->at(i)); 
     }
#2

Updated by Rogers, Chris over 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Will be pushed on next push of #1376

#3

Updated by Rajaram, Durga over 9 years ago

  • Target version changed from Future MAUS release to MAUS-v0.8.4

Also available in: Atom PDF