Skip to content

Fix segfault from <attach> mjCwrap#3157

Open
mar-yan24 wants to merge 1 commit intogoogle-deepmind:mainfrom
mar-yan24:mark-segfaultfix
Open

Fix segfault from <attach> mjCwrap#3157
mar-yan24 wants to merge 1 commit intogoogle-deepmind:mainfrom
mar-yan24:mark-segfaultfix

Conversation

@mar-yan24
Copy link
Copy Markdown
Contributor

Summary

Fixes #3152: Accessing MjsTendonPath.MjsWrap Python bindings causes a segfault with a body/attach model

It honestly took me sorta a long time to trace/figure this out but the bug originates in mjCTendon::CopyFromSpec() in src/user/user_objects.cc.

When the model is loaded using the block, MuJoCo runs CopyList() for each of the tendons:
candidate->model = this;
candidate->CopyFromSpec();
candidate->ResolveReferences(this);

This shows you how the model gets updated, but CopyFromSpec() never propagated that to the mjCWrap objects in path[]. This means that each wrap had like a null or old pointer from the child.

This solution also wasn't exactly new since the mjCTendon::SetMode() function already does this; I'm not sure why CopyFromSpec wasn't doing the same thing.

I lowkey decided on omitting the test-cases for this since it is such a small fix if that's ok.

@kevinzakka kevinzakka requested a review from quagla March 7, 2026 00:53
@mar-yan24 mar-yan24 changed the title Fix segfault from <attach> mjCwrap fix Fix segfault from <attach> mjCwrap Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessing MjsTendonPath.MjsWrap Python bindings causes a segfault with a body/attach model

2 participants