Home › Forum › SofaPython3 › Programming with SofaPython3 › [SOLVED] “m_ContactsVectorBuffer” not valid sometimes
Tagged: contactlistener, getContactElements, Linux_ubuntu, M_ContactsVectorBuffer, segfault, segmentation fault 11, SOFA_2012
- This topic has 9 replies, 4 voices, and was last updated 2 years, 7 months ago by
Hugo.
-
AuthorPosts
-
31 July 2021 at 17:52 #20108
Syoy
BlockedHey folks,
In my project I am using instances of the ContactListener class to detect the number of contacts between several meshes and the corresponding point indices. I am using the scene as a RL gym environment.
Now the problem:
-> once in a while segmentation fault 11 pops upI investigated this issue and found out that m_ContactsVectorBuffer seems to be not valid when this error occurs. When querying the number of contacts (getNumberOfContacts) before each call of contact elements it returns a count at least one magnitude smaller than the amount of times the loop over elements in m_ContactVectorBuffer in getContactElements() is iterated.
The returned indices in case of a following segmentation fault in the current iteration of m_ContactsVectorBuffer are also not valid (ints >> 10000000, when the meshes only have about 500 elements)SYoy
17 August 2021 at 11:36 #20178chiarasapo
BlockedHi @syoy, I have the same problem, did you happen to find a solution?
Chiara20 August 2021 at 12:14 #20185Syoy
BlockedI added a variable to count the loop cycles to the functions in the ContactListener.cpp file which ends the auto loop after getNumberOfContacts iterations.
I than handled wrong indices in Python.23 August 2021 at 18:29 #20209Hugo
KeymasterDear @syoy @chiarasapo
Thank you for reporting this issue.
It would be interesting to have a simple scene which reproduces it. Could you share a simple failing example?
This might be avoided by checking in all functions reading in m_ContactsVectorBuffer, that this vector is not empty. If so, returning an error. It would be nice @syoy if you could test and pull-request this.
Best,
Hugo
PS: note that a platform should be soon released on the use of SOFA + Gym. This should be presented officially at the SOFA Week 2021
24 August 2021 at 11:22 #20228chiarasapo
BlockedI did not see your reply before @syoy, thank you very much!! 🙂 In the end, I had solved the problem in the same way by just setting in the ContactListener.cpp functions main loops:
int count = 0;
for (const auto& c: m_ContactsVectorBuffer[0][0]){
if (++count > numberOfContacts) {
printf(“Error!\n”);
break;
}
…And the error I was obtaining before was:
########## SIG 11 – SIGSEGV: segfault ##########
47: sofa::helper::BackTrace::dump – 0x7ff9f86b67d046: sofa::helper::BackTrace::sig – 0x7ff9f86b695045: seh_filter_exe – 0x7ffa60a10cc044: seh_filter_exe – 0x7ffa60a10cc043: _C_specific_handler – 0x7ffa5c52eb2042: _chkstk – 0x7ffa6331206041: RtlRaiseException – 0x7ffa632c102040: KiUserExceptionDispatcher – 0x7ffa63310c8039: sofa::core::collision::ContactListener::getContactElements – 0x7ff9f85f730038: sofa::core::collision::ContactListener::getContactElements – 0x7ff9f85f730037: sofa::core::collision::ContactListener::getContactElements – 0x7ff9f85f730036: PyMethodDef_RawFastCallKeywords – 0x7ff9f472dd2035: PyCFunction_FastCallKeywords – 0x7ff9f475afc034: PyFunction_FastCallDict – 0x7ff9f472d54033: PyEval_EvalFrameDefault – 0x7ff9f473442032: PyFunction_FastCallDict – 0x7ff9f472d54031: PyUnicode_Compare – 0x7ff9f474d05030: PyObject_Call – 0x7ff9f471be4029: PyObject_Call – 0x7ff9f471be4028: PyObject_Call – 0x7ff9f471be4027: sofa::simulation::PropagateEventVisitor::processNodeTopDown – 0x7ff9f8827d0026: sofa::simulation::graph::DAGNode::executeVisitorTopDown – 0x7ffa44d17cd025: sofa::simulation::graph::DAGNode::doExecuteVisitor – 0x7ffa44d1748024: sofa::component::animationloop::FreeMotionAnimationLoop::step – 0x7ff9f203da1023: sofa::simulation::Simulation::animate – 0x7ff9f882aa2022: sofa::gui::qt::RealGUI::step – 0x7ff9f781b55021: QObject::qt_static_metacall – 0x7ff9f5a4094020: QTimer::timerEvent – 0x7ff9f5a509c019: QObject::event – 0x7ff9f5a4945018: QApplicationPrivate::notify_helper – 0x7ff9f64f488017: QApplication::notify – 0x7ff9f64f216016: QCoreApplication::notifyInternal2 – 0x7ff9f5a22a1015: QEventDispatcherWin32::event – 0x7ff9f5a6b6b014: QApplicationPrivate::notify_helper – 0x7ff9f64f488013: QApplication::notify – 0x7ff9f64f216012: QCoreApplication::notifyInternal2 – 0x7ff9f5a22a1011: QCoreApplicationPrivate::sendPostedEvents – 0x7ff9f5a2463010: qt_plugin_query_metadata – 0x7ff9f1300e409: QEventDispatcherWin32::processEvents – 0x7ff9f5a6b9f08: qt_plugin_query_metadata – 0x7ff9f1300e407: QEventLoop::exec – 0x7ff9f5a1ed706: QCoreApplication::exec – 0x7ff9f5a219405: sofa::gui::qt::RealGUI::mainLoop – 0x7ff9f7817cc04: sofa::gui::GUIManager::MainLoop – 0x7ffa28902d503: sofa::gui::GUIManager::MainLoop – 0x7ffa28902d502: sofa::gui::GUIManager::MainLoop – 0x7ffa28902d501: BaseThreadInitThunk – 0x7ffa631570200: RtlUserThreadStart – 0x7ffa632c2630I hope it is useful, thank you both for your kind help!
24 August 2021 at 11:24 #20229Hugo
Keymasterhi @chiarasapo
Would you agree to share this code by making a pull-request on GitHub?
Best wishes,Hugo
24 August 2021 at 15:08 #20232chiarasapo
BlockedSure!
1 October 2021 at 09:44 #20475Hugo
Keymasterhi @chiarasapo
have you done a PR? I was a bit busy these days and I might have missed it.
Best,Hugo
8 February 2022 at 11:45 #214758 February 2022 at 12:28 #21476Hugo
KeymasterGreat, thanks @scheikl! That’s awesome!
Best wishes,
Hugo
—
NOTE: we are now moving the forum to GitHub Discussions. Do not hesitate to start using it already!
More information on the migration process can be found online. -
AuthorPosts
- You must be logged in to reply to this topic.