Skip to content

fix: prevent segfault in mjCModel::ResolvePlugin when instance is missing#3363

Merged
copybara-service[bot] merged 4 commits into
google-deepmind:mainfrom
ebms03:fix-resolve-plugin-segfault
Jul 14, 2026
Merged

fix: prevent segfault in mjCModel::ResolvePlugin when instance is missing#3363
copybara-service[bot] merged 4 commits into
google-deepmind:mainfrom
ebms03:fix-resolve-plugin-segfault

Conversation

@ebms03

@ebms03 ebms03 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

When looking up a plugin instance name that does not exist,

<plugin plugin="mujoco.pid">
  <instance name="my_pid_config" /> 
</plugin>
...
<actuator>
  <plugin instance="pid_config" ... /> <!-- wrong name -->
</actuator>

there is a null check in mjCModel::RegisterPlugin for throwing an error if the instance can't be found,

void mjCModel::ResolvePlugin(..., mjCPlugin** plugin_instance) {
    ...
    (*plugin_instance)->plugin_slot = plugin_slot;
    if (!*plugin_instance) {

but the pointer is dereferenced before the the null check. Moving the plugin slot assignment to after this check fixes it. The added test fails due to a segfault before the change, but passes afterwards.

ebms03 added 3 commits July 13, 2026 16:58
Remove trailing whitespace
Remove trailing whitespace
@quagla
quagla removed the request for review from havess July 14, 2026 08:12
@copybara-service
copybara-service Bot merged commit b7af32a into google-deepmind:main Jul 14, 2026
21 of 22 checks passed
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.

3 participants