-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python operations on shape nodes crash #184
Comments
My rough guess here is that in this example, the actual C++ structure for If my hunch about root cause is right, then this may be a tricky bug to solve, because it would probably require bringing back |
@keenon I don't think it's as simple as that. I found this in code where it keeps the skeleton around much longer. I simply can never access getName or getShape without a segfault. Thanks for the suggestion, I'm going to look into trying reference_internal. |
Good luck! I'd highly recommend reading the docs on return value policies in pybind11 (https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies), and then looking at the corresponding Python bindings (for example, the binding for Skeleton here: https://github.com/keenon/nimblephysics/blob/master/python/_nimblephysics/dynamics/Skeleton.cpp) |
Thanks, looks like a good reference. I'm finding quite an odd pattern of crashes using the shapeNodes. I also found even calling getBodyNodes() and letting the code end would crash (perhaps that has been changed on a more recent block of code, but I'm working near where the regression occurrred). Hopefully this can also help me figure out how to avoid needing to manually delete the fitMarkers to avoid segfaults from that, too.
|
@keenon so I spent a while trying to see if anything about the return type around the methods would prevent the crash and had no success. I have two possible solutions that fix the crash. The first is reverting the move away from shared_ptr: This seems the most correct to me. Dart still has all of these classes defined as shared_ptr. I can't really follow the logic of why this behavior was changed, so perhaps I am missing some context. On this branch, all of the calls above go through without crashing. Another solution that is less elegant but more compact is here master...peabody124:nimblephysics:get_shape_crash_fix which basically exposes a new method that gets the shape directly from the body node and doesn't go through python to trigger bad garbage collection. Thoughts? Happy to submit a PR. p.s., any thoughts about adding python unit tests? |
Here's a fix that works on my local machine, without rollback: #186 It turned out there are two issues. One is an incorrect handling of ownership of |
Thanks. That fixes the main issues I was concerned about. There are still two crashes in my test cases using 0.9.10 (that weren't there on the revert branch). Both of these commented lines below do it:
|
Also while bringing these things up I've also found this code segfaults without the del fitMarkers
|
@keenon I found another related bug:
Also crashes after a few nodes. It seems to crash after getting the name before printing the shape. I'm wondering from extrapolating from your prior fix if a getShape needs to be defined here? |
I've tracked down a regression in the python bindings that causes a segafult when nimblephysics when from 0.8.77 to 0.8.78
This can be easily reproduced with:
it also occurs with getShape()
This can be reproduced in the devcontainer, too.
I'm pretty sure this change https://github.com/keenon/nimblephysics/pull/105/files#diff-a5184a1951f89b1f86b8b45fd5157f4bdb0be20ea8c62e8fefa74cc2c28371dc or the similar one in ShapeFrame is related, but I'm not certain how
The text was updated successfully, but these errors were encountered: