[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-dev] Particle removal and deactivation



Daniel Russel wrote:
Ben Webb wrote:
The testcase tried to use a Python reference to a particle which had already been deleted. This clearly won't work, which is why I fixed it in the patch. Running that testcase through valgrind clearly showed access to freed memory, as I wrote in the svn log. By all means, submit a patch which fixes the bug if you like. But the reference counting clearly does not work with Python right now, and I don't have time to fix this the "right" way.
No. The nbl should have been keeping the particle alive until the evaluate call (and the evaluate call will have memory issues if the memory is no longer valid since it needs to check if the particle is active or not). So there are probably deeper bugs.

Indeed. You can reproduce the problem with the following:
% cd imp/kernel/test/states
% svn up -r580 test_nonbonded_list.py
% ../../../bin/imppy.sh valgrind --suppressions=../../../tools/valgrind-python.supp python test_nonbonded_list.py -v > /dev/null

With latest SVN, this will run through and report 0 errors. With r580, you'll get stuff like the following:

Test bbox NBL ... ==10105== Invalid read of size 1
==10105==    at 0x46C509B: _wrap_Particle_get_is_active (IMP_wrap.cc:3544)
==10105== by 0x27D758C: PyCFunction_Call (in /usr/lib/libpython2.5.so.1.0)
==10105==    by 0x27A30B6: PyObject_Call (in /usr/lib/libpython2.5.so.1.0)
==10105== by 0x2825E7E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x2828D74: PyEval_EvalCodeEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x2827448: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x282862E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x282862E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x282862E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x2828D74: PyEval_EvalCodeEx (in /usr/lib/libpython2.5.so.1.0)
==10105==    by 0x27C2EB1: (within /usr/lib/libpython2.5.so.1.0)
==10105==    by 0x27A30B6: PyObject_Call (in /usr/lib/libpython2.5.so.1.0)
==10105==  Address 0x4a162ac is 20 bytes inside a block of size 76 free'd
==10105==    at 0x40054AA: operator delete(void*) (vg_replace_malloc.c:342)
==10105==    by 0x48AC2B8: IMP::Particle::~Particle() (Particle.cpp:23)
==10105== by 0x48A6573: IMP::internal::ObjectContainer<IMP::Particle, IMP::Index<IMP::ParticleTag> >::unref(IMP::Particle*) (ObjectContainer.h:55) ==10105== by 0x48AAB6E: IMP::internal::ObjectContainer<IMP::Particle, IMP::Index<IMP::ParticleTag> >::remove(IMP::Index<IMP::ParticleTag>) (ObjectContainer.h:95) ==10105== by 0x48A3666: IMP::Model::remove_particle(IMP::Index<IMP::ParticleTag>) (Model.cpp:34)
==10105==    by 0x46B8168: _wrap_Model_remove_particle (IMP_wrap.cc:14118)
==10105== by 0x27D758C: PyCFunction_Call (in /usr/lib/libpython2.5.so.1.0)
==10105==    by 0x27A30B6: PyObject_Call (in /usr/lib/libpython2.5.so.1.0)
==10105== by 0x2825E7E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x2828D74: PyEval_EvalCodeEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x2827448: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0) ==10105== by 0x282862E: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0)
==10105==

	Ben
--
                      http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle