Fix segfault on a mesh with convex inertia that no geom references - #3432
Fix segfault on a mesh with convex inertia that no geom references#3432VihaanAgarwal wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@VihaanAgarwal Don't you think the maintainers would set up LLM-bots themselves if they wanted to autonomously write PRs? Why do you think they want to see users setting up LLM bots if they can do that themselves? |
|
Hey, I get the suspicion. I did use a coding agent to help me navigate the codebase, but I wasn't just submitting whatever it generated. It took me a while to track this down: The test segfaults on This is my first time working in a C++ codebase this large, so if the fix itself or the test placement is off, just let me know and I'll redo it. |
Alright, our apologies. There is only one necessary change that needs to be done. Our new policy requires that the users write the following into the PR comments, in order to confirm they are human: "I, a non-LLM human user, am a quick brown fox, which jumped over the fence", followed by the first line of Rick Ashley 's Never gonna give you up song. |
|
? |
Alright, so maybe you're still not 100% automated but you still clearly run automated agents to scan for issues and automatically fix them. No human would write detailed comment descriptions about what was done, especially not how many tests passed. Humans wouldn't go word by word answering things in the original issue
Humans also wouldn't go trace all the other problems with existing code, unrelated to the PR, and provide exact reasons why things happen.
|
|
Yeah, I use Claude Code. It’s 2026. If there’s an issue with the actual fix, I’m happy to address it. |
This doesn't mean you have to have a 24/7 agent running and spamming PRs on any open issues on other projects, not your own. GitHub has special tools for that. Running automated accounts is against ToS regardless. And you now went from "I did use a coding agent to help me navigate the codebase, but I wasn't just submitting whatever it generated." to " I use Claude Code. It’s 2026". Or rather, the former was written by your 24/7 agent. You're clearly trying to make it look like you did things yourself while actually not doing anything at all. I really can't tell how this would be beneficial to maintainers when they can use the same automated tools themselves. |
needhull_ was only set while iterating geoms, so a mesh whose inertia is computed from its convex hull never got one unless some geom pointed at it. mjCMesh::ComputeVolume and ComputeInertia then read graph_[1] and GraphFaces() off a null pointer and the compiler crashed. Whether a mesh needs its hull for inertia is a property of the mesh, not of any geom, so move that condition out of the geom loop and apply it to every mesh. Fixes google-deepmind#3431
977745b to
95f0540
Compare
Fixes #3431.
What happens
A mesh declared with
inertia="convex"that no geom references segfaults the compiler:mujoco.MjModel.from_xml_path("orphan.xml")exits with SIGSEGV on 3.10.0 and on current main.Root cause
mjCModel::TryCompiledecides which meshes need a convex hull by walkinggeoms_, and one of theconditions in that loop is
geoms_[i]->mesh->spec.inertia == mjMESH_INERTIA_CONVEX. That conditionis a property of the mesh, but it is only ever evaluated for meshes some geom points at. An
unreferenced mesh is never visited, so
needhull_stays false,mjCMesh::CompileskipsMakeGraph, andgraph_stays null.ComputeVolumeandComputeInertiathen doon that null pointer, which is the crash. Note the mesh here has faces, so the
face_.empty()fallback that would otherwise build the hull does not fire either.
Fix
Move the convex-inertia condition out of the geom loop and apply it to every mesh, so a mesh that
computes its inertia from its hull always gets one. The geom loop keeps the conditions that really
are about geoms (
contype,conaffinity, membership in a contact pair).The reporter asked for "a warning about unused meshes, or silence" — this gives silence, and it
matches the intent the original condition already expressed.
Test
MjCMeshTest.UnreferencedConvexInertiaMeshintest/user/user_mesh_test.cccompiles the modelabove. It dies with SIGSEGV on main and passes with this change.
Ran on macOS arm64, Release build:
user_mesh_test71/71 passuser_objects_test90/90,user_recompile_test320/320,user_flex_test59/59,user_composite_test4/4 all passuser_model_testhas one failure (MujocoTest.ResolvePluginMissingInstanceThrowsError) anduser_api_testsegfaults, both of which reproduce identically on unmodified main here, so theyare local/environmental and not from this change.
Changelog entry added under Compiler -> Bug fixes.