Crash when starting a program using execve

I have a program that works perfectly fine when started from a shell and in a number of other ways.

Now I am attempting to start it as part of an automatic test environment. This environment sends request to a daemon process on the same machine instructing it to start another daemon process.

When doing so it crashes with a stack like below.

The start daemon process stopped starting after I killed it and rebuilt it. After a restart it was possible to start it again.

Here is the stack trace of the crash of the started program: Thread 0 Crashed: 0 dyld 0x104cc22c8 dyld3::MachOFile::compatibleSlice(Diagnostics&, void const*, unsigned long, char const*, dyld3::Platform, bool, dyld3::GradedArchs const&) + 76 1 dyld 0x104ca6758 invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int) + 96 2 dyld 0x104ca6758 invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int) + 96 3 dyld 0x104cabb44 dyld4::SyscallDelegate::withReadOnlyMappedFile(Diagnostics&, char const*, bool, void (void const*, unsigned long, bool, dyld4::FileID const&, char const*) block_pointer) const + 128 4 dyld 0x104ca66c4 dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int) + 204 5 dyld 0x104ca0580 invocation function for block in dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&) + 1412 6 dyld 0x104c9fa70 dyld4::Loader::forEachResolvedAtPathVar(dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, dyld4::ProcessConfig::PathOverrides::Type, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) + 780 7 dyld 0x104c9f6d8 invocation function for block in dyld4::Loader::forEachPath(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) + 116 8 dyld 0x104c962f4 invocation function for block in dyld4::ProcessConfig::PathOverrides::forEachPathVariant(char const*, dyld3::Platform, bool, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) const + 160 9 dyld 0x104c950dc dyld4::ProcessConfig::PathOverrides::forEachInColonList(char const*, char const*, void (char const*, bool&) block_pointer) + 248 10 dyld 0x104c95d48 dyld4::ProcessConfig::PathOverrides::forEachPathVariant(char const*, dyld3::Platform, bool, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) const + 344 11 dyld 0x104c9f64c dyld4::Loader::forEachPath(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) + 172 12 dyld 0x104c9fdf8 dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&) + 840 13 dyld 0x104ca4968 invocation function for block in dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&) + 380 14 dyld 0x104cc0ffc invocation function for block in dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 148 15 dyld 0x104c8df98 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 168 16 dyld 0x104cc0e3c dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 172 17 dyld 0x104ca46d0 dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&) + 164 18 dyld 0x104c91618 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 1076 19 dyld 0x104c910d4 start + 488

Here is the crash report from the start program when it failed to start:


Translated Report (Full Report Below)

Incident Identifier: 109F9038-237A-4D87-ADD4-061B67285290 CrashReporter Key: 2D5BE3DF-FBCA-31AD-0DA6-D043D067754B Hardware Model: MacBookPro18,3 Process: ndb_cpcd [64340] Path: /Users/USER/*/ndb_cpcd Identifier: ndb_cpcd Version: ??? Code Type: ARM-64 (Native) Role: Unspecified Parent Process: launchd [1] Coalition: com.apple.Terminal [502] Responsible Process: Terminal [508]

Date/Time: 2021-12-09 02:21:15.9544 +0100 Launch Time: 2021-12-09 02:21:15.9504 +0100 OS Version: macOS 12.0.1 (21A559) Release Type: User Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid)) Exception Subtype: UNKNOWN_0x32 at 0x0000000102208000 Exception Codes: 0x0000000000000032, 0x0000000102208000 VM Region Info: 0x102208000 is in 0x102208000-0x1025bc000; bytes after start: 0 bytes before end: 3883007 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> mapped file 102208000-1025bc000 [ 3792K] r-x/r-x SM=COW ...t_id=5481c8e5 mapped file 1025bc000-1025c4000 [ 32K] rw-/rw- SM=COW ...t_id=5481c8e5 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: CODESIGNING 2

Highlighted by Thread: 0

Backtrace not available

No thread state (register information) available

Binary Images: 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

Error Formulating Crash Report: dyld_process_info_create failed with 6 dyld_process_snapshot_get_shared_cache failed Failed to create CSSymbolicatorRef - corpse still valid ¯_(ツ)

EOF

Crash when starting a program using execve
 
 
Q