[Monterey 12.2 - XCode 13.2] App crash when launch within XCode

Hi!

When trying to debug my application within Xcode, it built successfully but the app crash at startup with this backtrace:

Thread 1#0	0x000000013569cb48 in strcpy ()
#1	0x00000001356a4515 in dyld4::ProcessConfig::PathOverrides::setString(dyld4::ProcessConfig::Process const&, char const*&, char const*) ()
#2	0x00000001356a3c87 in dyld4::ProcessConfig::PathOverrides::addEnvVar(dyld4::ProcessConfig::Process const&, dyld4::ProcessConfig::Security const&, char const*, bool, char*) ()
#3	0x00000001356a3947 in dyld4::ProcessConfig::PathOverrides::PathOverrides(dyld4::ProcessConfig::Process const&, dyld4::ProcessConfig::Security const&, dyld4::ProcessConfig::Logging const&, dyld4::ProcessConfig::DyldCache const&, dyld4::SyscallDelegate&) ()
#4	0x00000001356a0466 in start ()

Interestingly enough, if I run the produced binary within lldb directly it's working.

I tried with Big Sur and Xcode 13.2, it's working correctly within XCode, this issue seems related to Monterey.

Details my app is a C++ / Objective-C app.

For us this crash was because DYLD_LIBRARY_PATH was too long. There are other env variables that could be causing it as well. We solved it by not having a unique BUILT_PRODUCTS_DIR for each target in the dependency tree.

[Monterey 12.2 - XCode 13.2] App crash when launch within XCode
 
 
Q