MacOS App compiled with Deployment 10.10 on Catalina crashes on versions < HighSierra due to ____chkstk_darwin

Viewed 1051

We have a multi-platform desktop application that uses a common component written in C++. The component uses OpenSSL and PocoProject - both are statically linked into the library.

On macOS - we have a small Framework written in Objective-C - it's essentially single h/cpp wrapper for the C++ code. It enables macOS developers to use the component easily (using Swift). The XCode project for the Framework and also the XCode project for the Application has DeploymentTarget set to 10.10 (Yosemite).

This setup has been working great for years - but we are now facing major trouble after upgrading our development environment to Catalina (XCode version 11.14.1 - Apple clang version 11.0.3 (clang-1103.0.32.59)).

Our application crashes brutally when running it on HighSierra, Sierra, El Capitain, Yosemite (after it has been built on Catalina - with 10.10 as deployment target).

Code Type:             X86-64 (Native)
Parent Process:        bash [345]
Responsible:           XXXCoreMacOSTestApp [845]
User ID:               501

Date/Time:             2020-05-18 21:45:43.354 +0200
OS Version:            Mac OS X 10.13.6 (17G66)
Report Version:        12
Anonymous UUID:        2FE97D01-7DEF-32CB-E57B-CDFB7A600D8F

Sleep/Wake UUID:       68646DF3-E40E-463D-A390-E90F56D5EA6E

Time Awake Since Boot: 3200 seconds
Time Since Wake:       1700 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x4] Symbol missing

Application Specific Information:
Performing @selector(Test:) from sender NSButton 0x7fcb724207a0

Dyld Error Message:
  Symbol not found: ____chkstk_darwin
  Referenced from: /Users/USER/Desktop/XXXCoreMacOSTestApp.app/Contents/MacOS/../Frameworks/XXXCoreMacOSWrapper.framework/Versions/A/XXXCoreMacOSWrapper
  Expected in: /usr/lib/libSystem.B.dylib

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   dyld                           0x0000000114a2f24a __abort_with_payload + 10
1   dyld                           0x0000000114a2ebbc abort_with_payload_wrapper_internal + 89
2   dyld                           0x0000000114a2ebe9 abort_with_payload + 9
3   dyld                           0x0000000114a02482 dyld::halt(char const*) + 354
4   dyld                           0x0000000114a025a9 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 170
5   libdyld.dylib                 0x00007fff7b8a3292 dyld_stub_binder + 282
6   ???                           0x0000000106a48000 0 + 4406411264
7   com.xxx.XXXCoreMacOSWrapper 0x00000001067af2e7 ssl3_write_bytes + 2871
8   com.xxx.XXXCoreMacOSWrapper 0x00000001067e52ad ssl3_do_write + 61
9   com.xxx.XXXCoreMacOSWrapper 0x00000001067dc057 state_machine + 1271
10  com.xxx.XXXCoreMacOSWrapper 0x000000010665cf58 Poco::Net::SecureSocketImpl::connectSSL(bool) + 328
11  com.xxx.XXXCoreMacOSWrapper 0x000000010665d29b Poco::Net::SecureSocketImpl::connect(Poco::Net::SocketAddress const&, Poco::Timespan const&, bool) + 203
12  com.xxx.XXXCoreMacOSWrapper 0x000000010666047c Poco::Net::SecureStreamSocketImpl::connect(Poco::Net::SocketAddress const&, Poco::Timespan const&) + 28
13  com.xxx.XXXCoreMacOSWrapper 0x00000001066aad06 Poco::Net::HTTPSession::connect(Poco::Net::SocketAddress const&) + 22

The application tries to dynamically load /usr/lib/libSystem.B.dylib and invoke a chkstk (checkstack) method ____chkstk_darwin. I guess it's the compiler that adds this check?

I have inspected the C++ libraries with oTool - and they do not have any dependencies on shared libraries. I see form oTool that it's the macOS framework wrapper that adds this dependency.

Our developers want to use the newest xcode/swift version - so we don't want to go back to older macOS/XCode versions.

How do I get around this issue? Are there any compiler flags that can be helpful?

1 Answers

The issue is how the static libraries for OpenSSL and PocoProject were compiled. They also need to be compiled with the deployment target set to 10.10. The deployment target would be what prevents the compiler from inserting that call to the chkstk function.

More generally, all of the code must be compiled with the deployment target set in order for it to deploy successfully to OS versions earlier than the build OS.

When invoking the compiler directly, you can pass -mmacosx-version-min=10.10 as a compiler option to set the deployment target. Alternatively, you can set the environment variable MACOSX_DEPLOYMENT_TARGET to "10.10" for the compiler invocation to achieve the same thing.

Related