Skip to content

VFS crash (basic_string: construction from null is not valid) when directory is NULL. #2839

@davidhozic

Description

@davidhozic

Intro

Hi!

I am a graduate student at University of Ljubljana, I use MuJoCo for RL.

My setup

MuJoCo 3.3.5, C API, x86_64, Ubuntu 24.04.3 LTS (Kubuntu).

What's happening? What did you expect?

When trying to add a real file to the virtual file system and the directory is given argument NULL, an exception basic_string: construction from null is not valid is thrown,
before crashing.

Based on the documentation, the directory parameter is allowed to be NULL:

mj_addFileVFS
int mj_addFileVFS(mjVFS* vfs, const char* directory, const char* filename);
Add file to VFS. The directory argument is optional and can be NULL or empty. Returns 0 on success, 2 on name collision, or -1 when an internal error occurs.

Nullable: directory

Steps for reproduction

Try to pass NULL as the directory parameter in mj_addFileVFS.

Minimal model for reproduction

No model is used.

Code required for reproduction

int main(int argc, char** argv) {

    mjVFS vfs;
    mj_defaultVFS(&vfs);

    mj_addFileVFS(&vfs, NULL, "test.c");

    mj_deleteVFS(&vfs);

    return 0;
}

Confirmations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions