conda-forge / mujoco-feedstock

A conda-smithy repository for mujoco.
BSD 3-Clause "New" or "Revised" License
1 stars 4 forks source link

Unsigned `mjpython` executable causes SIGKILL on OSX #64

Open flferretti opened 1 month ago

flferretti commented 1 month ago

Solution to issue cannot be found in the documentation.

Issue

The mjpython (version 3.2.0) executable in the Mujoco environment crashes immediately upon launch due to a code signing validation error, resulting in a SIGKILL signal. After checking the code signature with codesign --verify --deep $(which mjpython), I get:

$ codesign --verify --deep $(which mjpython)               
~/miniforge3/envs/mjtest/bin/mjpython: code object is not signed at all
Translated Report

```yaml Incident Identifier: 404B9CA7-D59D-4C05-88F4-E058AC8E67F1 CrashReporter Key: 5D3FABD9-F098-B403-B043-D8CBE9964F43 Hardware Model: Macmini9,1 Process: mjpython [55412] Path: /Users/USER/*/MuJoCo (mjpython).app/Contents/MacOS/mjpython Identifier: org.mujoco.mjpython Version: 3.2.0 (3.2.0) Code Type: ARM-64 (Native) Role: Unspecified Parent Process: zsh [54238] Coalition: com.apple.Terminal [6864] Responsible Process: Terminal [46050] Date/Time: 2024-10-16 16:21:28.3124 +0200 Launch Time: 2024-10-16 16:21:26.7155 +0200 OS Version: macOS 15.1 (24B5070a) Release Type: User Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid)) Exception Subtype: UNKNOWN_0x32 at 0x0000000102170000 Exception Codes: 0x0000000000000032, 0x0000000102170000 VM Region Info: 0x102170000 is in 0x102170000-0x102174000; bytes after start: 0 bytes before end: 16383 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 102170000-102174000 [ 16K] r-x/r-x SM=COW /main_executable_path_missing __DATA_CONST 102174000-102178000 [ 16K] rw-/rw- SM=COW /main_executable_path_missing Termination Reason: CODESIGNING 2 Invalid Page Triggered by Thread: 0 Thread 0 Crashed: 0 dyld_path_missing 0x10237e1e4 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 52 1 dyld_path_missing 0x10238026c dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const + 160 2 dyld_path_missing 0x1023ca810 dyld3::MachOFile::isBuiltForSimulator() const + 124 3 dyld_path_missing 0x102381e3c start + 1760 Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000102170000 x1: 0x000000016dc8f0d8 x2: 0x000000016dc8f080 x3: 0x000000010237de24 x4: 0x0000000000000001 x5: 0x0000000000000073 x6: 0x0000000000000000 x7: 0x0000000000000d10 x8: 0x000000016dc8f0b8 x9: 0x0000000102403458 x10: 0x00000001023ed000 x11: 0x00000001023faba6 x12: 0x0000000000000065 x13: 0x0000000000000073 x14: 0x000000000004bca0 x15: 0x0000000000000000 x16: 0x000000010238030c x17: 0x6ae100016dc8f080 x18: 0x0000000000000000 x19: 0x000000016dc8f0d8 x20: 0x0000000102170000 x21: 0x000000016dc8f080 x22: 0x000000016dc8f3c8 x23: 0x0000000000000000 x24: 0x0000000000000000 x25: 0x0000000000000000 x26: 0x0000000000000000 x27: 0x0000000000000000 x28: 0x0000000000000000 fp: 0x000000016dc8f070 lr: 0x000000010238026c sp: 0x000000016dc8efe0 pc: 0x000000010237e1e4 cpsr: 0x80001000 far: 0x0000000102170000 esr: 0x92000007 (Data Abort) byte read Translation fault Binary Images: 0x10237c000 - 0x1023fffff dyld_path_missing (*) <30a1d1f9-6c45-33af-99f5-6899bded46ab> /dyld_path_missing 0x102170000 - 0x102173fff main_executable_path_missing (*) <4ba80ae6-96ad-30fe-8cc7-06c125f58689> /main_executable_path_missing 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ??? Error Formulating Crash Report: dyld_process_snapshot_get_shared_cache failed ```

Full Report JSON

```json {"app_name":"mjpython","timestamp":"2024-10-16 16:21:28.00 +0200","app_version":"3.2.0","slice_uuid":"4ba80ae6-96ad-30fe-8cc7-06c125f58689","build_version":"3.2.0","platform":0,"bundleID":"org.mujoco.mjpython","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 15.1 (24B5070a)","roots_installed":0,"name":"mjpython","incident_id":"404B9CA7-D59D-4C05-88F4-E058AC8E67F1"} { "uptime" : 20000, "procRole" : "Unspecified", "version" : 2, "userID" : 501, "deployVersion" : 210, "modelCode" : "Macmini9,1", "coalitionID" : 6864, "osVersion" : { "train" : "macOS 15.1", "build" : "24B5070a", "releaseType" : "User" }, "captureTime" : "2024-10-16 16:21:28.3124 +0200", "codeSigningMonitor" : 1, "incident" : "404B9CA7-D59D-4C05-88F4-E058AC8E67F1", "pid" : 55412, "translated" : false, "cpuType" : "ARM-64", "roots_installed" : 0, "bug_type" : "309", "procLaunch" : "2024-10-16 16:21:26.7155 +0200", "procStartAbsTime" : 482057279739, "procExitAbsTime" : 482093024906, "procName" : "mjpython", "procPath" : "\/Users\/USER\/*\/MuJoCo (mjpython).app\/Contents\/MacOS\/mjpython", "bundleInfo" : {"CFBundleShortVersionString":"3.2.0","CFBundleVersion":"3.2.0","CFBundleIdentifier":"org.mujoco.mjpython"}, "storeInfo" : {"deviceIdentifierForVendor":"F060D8CB-21B5-5998-9088-E9B381D8D414","thirdParty":true}, "parentProc" : "zsh", "parentPid" : 54238, "coalitionName" : "com.apple.Terminal", "crashReporterKey" : "5D3FABD9-F098-B403-B043-D8CBE9964F43", "responsiblePid" : 46050, "responsibleProc" : "Terminal", "codeSigningID" : "", "codeSigningTeamID" : "", "codeSigningFlags" : 16777728, "codeSigningValidationCategory" : 0, "codeSigningTrustLevel" : 4294967295, "instructionByteStream" : {"beforePC":"+mcFqfhfBqn2Vwep9E8Iqf17Can9QwKR9QMCqvMDAar0AwCq\/\/8AOQ==","atPC":"CABAuelZn1Kp3b9yHwEJa+AAAFTJWZ9Sqd2\/ch8BCWthAQBUiQOAUg=="}, "bootSessionUUID" : "0E7FD772-2EA7-408F-9497-940DD6239FA0", "sip" : "enabled", "vmRegionInfo" : "0x102170000 is in 0x102170000-0x102174000; bytes after start: 0 bytes before end: 16383\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> __TEXT 102170000-102174000 [ 16K] r-x\/r-x SM=COW \/main_executable_path_missing\n __DATA_CONST 102174000-102178000 [ 16K] rw-\/rw- SM=COW \/main_executable_path_missing", "exception" : {"codes":"0x0000000000000032, 0x0000000102170000","rawCodes":[50,4330029056],"type":"EXC_BAD_ACCESS","signal":"SIGKILL (Code Signature Invalid)","subtype":"UNKNOWN_0x32 at 0x0000000102170000"}, "termination" : {"flags":0,"code":2,"namespace":"CODESIGNING","indicator":"Invalid Page"}, "vmregioninfo" : "0x102170000 is in 0x102170000-0x102174000; bytes after start: 0 bytes before end: 16383\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> __TEXT 102170000-102174000 [ 16K] r-x\/r-x SM=COW \/main_executable_path_missing\n __DATA_CONST 102174000-102178000 [ 16K] rw-\/rw- SM=COW \/main_executable_path_missing", "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "faultingThread" : 0, "threads" : [{"triggered":true,"id":447441,"threadState":{"x":[{"value":4330029056},{"value":6136852696},{"value":6136852608},{"value":4332183076},{"value":1},{"value":115},{"value":0},{"value":3344},{"value":6136852664},{"value":4332729432,"symbolLocation":0,"symbol":"__block_descriptor_tmp.70"},{"value":4332638208,"symbolLocation":24,"symbol":"dyld4::Atlas::ProcessSnapshot::Serializer::emitMappedFileInfo(unsigned long long, lsl::UUID const&, dyld4::FileRecord const&, lsl::Vector&) (.cold.2)"},{"value":4332694438},{"value":101},{"value":115},{"value":310432},{"value":0},{"value":4332192524,"symbolLocation":0,"symbol":"invocation function for block in dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const"},{"value":7701436843917111424},{"value":0},{"value":6136852696},{"value":4330029056},{"value":6136852608},{"value":6136853448},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4332192364},"cpsr":{"value":2147487744},"fp":{"value":6136852592},"sp":{"value":6136852448},"esr":{"value":2449473543,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4332184036,"matchesCrashFrame":1},"far":{"value":4330029056}},"frames":[{"imageOffset":8676,"symbol":"dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const","symbolLocation":52,"imageIndex":0},{"imageOffset":17004,"symbol":"dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const","symbolLocation":160,"imageIndex":0},{"imageOffset":321552,"symbol":"dyld3::MachOFile::isBuiltForSimulator() const","symbolLocation":124,"imageIndex":0},{"imageOffset":24124,"symbol":"start","symbolLocation":1760,"imageIndex":0}]}], "usedImages" : [ { "source" : "P", "arch" : "arm64e", "base" : 4332175360, "size" : 540672, "uuid" : "30a1d1f9-6c45-33af-99f5-6899bded46ab", "path" : "\/dyld_path_missing", "name" : "dyld_path_missing" }, { "source" : "P", "arch" : "arm64", "base" : 4330029056, "size" : 16384, "uuid" : "4ba80ae6-96ad-30fe-8cc7-06c125f58689", "path" : "\/main_executable_path_missing", "name" : "main_executable_path_missing" }, { "size" : 0, "source" : "A", "base" : 0, "uuid" : "00000000-0000-0000-0000-000000000000" } ], "vmSummary" : "ReadOnly portion of Libraries: Total=864K resident=0K(0%) swapped_out_or_unallocated=864K(100%)\nWritable regions: Total=8240K written=64K(1%) resident=64K(1%) swapped_out=0K(0%) unallocated=8176K(99%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nSTACK GUARD 56.0M 1 \nStack 8176K 1 \nVM_ALLOCATE 16K 1 \n__DATA 32K 2 \n__DATA_CONST 48K 2 \n__DATA_DIRTY 16K 1 \n__LINKEDIT 320K 2 \n__TEXT 544K 2 \n__TPRO_CONST 288K 1 \nmapped file 4.3G 14 \npage table in kernel 64K 1 \nshared memory 16K 1 \n=========== ======= ======= \nTOTAL 4.4G 29 \n", "legacyInfo" : { "threadTriggered" : { } }, "logWritingSignature" : "75d40bae3fd5b5b856dcb2d011a2541c4b14e442", "trialInfo" : { "rollouts" : [ { "rolloutId" : "5ffde50ce2aacd000d47a95f", "factorPackIds" : { }, "deploymentId" : 250000432 }, { "rolloutId" : "64628732bf2f5257dedc8988", "factorPackIds" : { }, "deploymentId" : 250000003 } ], "experiments" : [ { "treatmentId" : "c47ab4cc-c9c3-4b5d-a87c-e2433ce02597", "experimentId" : "6639bc6ba73d460582162323", "deploymentId" : 400000006 } ] }, "reportNotes" : [ "dyld_process_snapshot_get_shared_cache failed" ] } ```

Installed packages

# packages in environment at /Users/filippolucaferretti/miniforge3/envs/mjtest:
#
# Name                    Version                   Build  Channel
absl-py                   2.1.0              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                h99b78c6_7    conda-forge
ca-certificates           2024.8.30            hf0a4a13_0    conda-forge
etils                     1.9.4              pyhd8ed1ab_0    conda-forge
fsspec                    2024.9.0           pyhff2d567_0    conda-forge
glfw                      3.4                  h93a5062_0    conda-forge
importlib_resources       6.4.5              pyhd8ed1ab_0    conda-forge
libabseil                 20240116.2      cxx17_h00cdb27_1    conda-forge
libblas                   3.9.0           24_osxarm64_openblas    conda-forge
libcblas                  3.9.0           24_osxarm64_openblas    conda-forge
libccd-double             2.1                  h9a09cb3_2    conda-forge
libcxx                    19.1.2               ha82da77_0    conda-forge
libexpat                  2.6.3                hf9b8971_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0           13_2_0_hd922786_3    conda-forge
libgfortran5              13.2.0               hf226fd6_3    conda-forge
liblapack                 3.9.0           24_osxarm64_openblas    conda-forge
libmujoco                 3.2.0                h542f3a9_1    conda-forge
libopenblas               0.3.27          openmp_h517c56d_1    conda-forge
libsqlite                 3.46.1               hc14010f_0    conda-forge
libzlib                   1.3.1                h8359307_2    conda-forge
llvm-openmp               19.1.1               hb52a8e5_1    conda-forge
lodepng                   20220109             hf86a087_0    conda-forge
mujoco                    3.2.0                hce30654_1    conda-forge
mujoco-python             3.2.0           py312h09d7e93_1    conda-forge
mujoco-samples            3.2.0                hf9b8971_1    conda-forge
mujoco-simulate           3.2.0                hf9b8971_1    conda-forge
ncurses                   6.5                  h7bae524_1    conda-forge
numpy                     2.1.2           py312h801f5e3_0    conda-forge
openssl                   3.3.2                h8359307_0    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pyglfw                    2.7.0              pyha770c72_1    conda-forge
pyopengl                  3.1.6              pyhd8ed1ab_1    conda-forge
python                    3.12.7          h739c21a_0_cpython    conda-forge
python_abi                3.12                    5_cp312    conda-forge
qhull                     2020.2               h420ef59_5    conda-forge
readline                  8.2                  h92ec313_1    conda-forge
tinyxml2                  10.0.0               hebf3989_0    conda-forge
tk                        8.6.13               h5083fa2_1    conda-forge
typing_extensions         4.12.2             pyha770c72_0    conda-forge
tzdata                    2024b                hc8b5060_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
zipp                      3.20.2             pyhd8ed1ab_0    conda-forge
### Environment info

     active environment : None
            shell level : 0
       user config file : /Users/filippolucaferretti/.condarc
 populated config files : /Users/filippolucaferretti/miniforge3/.condarc
                          /Users/filippolucaferretti/.condarc
          conda version : 24.7.1
    conda-build version : 24.7.1
         python version : 3.10.14.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=m1
                          __conda=24.7.1=0
                          __osx=15.1=0
                          __unix=0=0
       base environment : /Users/filippolucaferretti/miniforge3  (writable)
      conda av data dir : /Users/filippolucaferretti/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/filippolucaferretti/miniforge3/pkgs
                          /Users/filippolucaferretti/.conda/pkgs
       envs directories : /Users/filippolucaferretti/miniforge3/envs
                          /Users/filippolucaferretti/.conda/envs
               platform : osx-arm64
             user-agent : conda/24.7.1 requests/2.32.3 CPython/3.10.14 Darwin/24.1.0 OSX/15.1 solver/libmamba conda-libmamba-solver/24.7.0 libmambapy/1.5.8
                UID:GID : 501:20
             netrc file : None
           offline mode : False
traversaro commented 1 month ago

Argh, I had no idea a mjpython executable was installed in macos at all. Do other mujoco executables work on Mac?

traversaro commented 1 month ago

https://github.com/google-deepmind/mujoco/commit/230e2780de5e3a973b79cb07b545da0764daf854

flferretti commented 1 month ago

Argh, I had no idea a mjpython executable was installed in macos at all. Do other mujoco executables work on Mac?

python -m mujoco.viewer works correctly, but when I try to launch the passive viewer from a script I get a runtime error as I'd need to launch the script with mjpython some_script.py:

    handle = mujoco.viewer.launch_passive(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: `launch_passive` requires that the Python script be run under `mjpython` on macOS

But then I get SIGKILL immediately.

traversaro commented 1 month ago

mujoco-simulate from mujoco-simulate package works?

flferretti commented 1 month ago

Yes, mujoco-simulate, mujoco-basic, mujoco-record, mujoco-testspeed, mujoco-compile and mujoco_plugin work correctly

traversaro commented 1 month ago

Possibly related issue: https://github.com/google-deepmind/mujoco/issues/1923 .