segmentation fault 11 ios swift 1.2 - xcode

I am new to stackoverflow, but I want to ask about the compiler error I got when compiling a swift project with some ObjC libraries.
`
0 swift 0x0000000100dbba18 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x0000000100dbbef4 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff9500ef1a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fff5f55b6e8 _sigtramp + 3394553832
4 swift 0x00000001009b284c (anonymous namespace)::ObjCPrinter::print(swift::Type, llvm::Optional<swift::OptionalTypeKind>, llvm::StringRef) + 108
5 swift 0x00000001009b6c9e std::__1::__function::__func<(anonymous namespace)::ModuleWriter::forwardDeclare(swift::EnumDecl const*)::'lambda'(), std::__1::allocator<(anonymous namespace)::ModuleWriter::forwardDeclare(swift::EnumDecl const*)::'lambda'()>, void ()>::operator()() + 238
6 swift 0x00000001009b6afc (anonymous namespace)::ModuleWriter::forwardDeclare(swift::NominalTypeDecl const*, std::__1::function<void ()>) + 236
7 swift 0x00000001009b6664 void llvm::function_ref<void ((anonymous namespace)::ReferencedTypeFinder&, swift::TypeDecl const*)>::callback_fn<(anonymous namespace)::ModuleWriter::forwardDeclareMemberTypes(swift::IteratorRange<swift::DeclIterator>)::'lambda'((anonymous namespace)::ReferencedTypeFinder&, swift::TypeDecl const*)>(long, (anonymous namespace)::ReferencedTypeFinder&, swift::TypeDecl const*) + 196
8 swift 0x00000001009b689f swift::TypeVisitor<(anonymous namespace)::ReferencedTypeFinder, void>::visit(swift::Type) + 207
9 swift 0x00000001009b690b swift::TypeVisitor<(anonymous namespace)::ReferencedTypeFinder, void>::visit(swift::Type) + 315
10 swift 0x00000001009b696b swift::TypeVisitor<(anonymous namespace)::ReferencedTypeFinder, void>::visit(swift::Type) + 411
11 swift 0x00000001009b02b8 (anonymous namespace)::ModuleWriter::forwardDeclareMemberTypes(swift::IteratorRange<swift::DeclIterator>) + 360
12 swift 0x00000001009af26d swift::printAsObjC(llvm::raw_ostream&, swift::Module*, llvm::StringRef, swift::Accessibility) + 2957
13 swift 0x00000001006a67ec printAsObjC(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, swift::Module*, llvm::StringRef, bool) + 332
14 swift 0x00000001006a5016 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 4998
15 swift 0x00000001006a3ae6 main + 1814
16 libdyld.dylib 0x00007fff927975c9 start + 1
17 libdyld.dylib 0x000000000000009e start + 1837533910
`
The project compiled and works fine on Xcode 6.2 and prior, but when I try to compile it on Xcode 6.3 and 6.3.1, I got Command failed due to signal : Segmentation fault 11. Can someone help me? Thanks before.
EDIT : Just for your info, I currently use two Xcode in one Mac, Xcode 6.2 and 6.3.1, because Xcode 6.3.x can't compile my project so I'm still using Xcode 6.2, while trying to fix for 6.3.x.

Related

Cannot decode object of class (MSACDeviceHistoryInfo) for key (NS.objects)

I have updated Appcenter from 3.2.2 to 5.0.1. Now I am getting exception in IOS when app calling AppCenter.Start with link behaviour "Link frameworks SDKs only". When I downgraded Appcenter I am still getting this exception. Exception disappears only if you delete the application from the phone and reinstall it.
Stacktrace:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidUnarchiveOperationException Reason: *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (MSACDeviceHistoryInfo) for key (NS.objects) because no class named "MSACDeviceHistoryInfo" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver
Native stack trace:
0 CoreFoundation 0x000000010e6928ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x0000000110c68ba3 objc_exception_throw + 48
2 Foundation 0x00000001150477d9 -[NSCoder __failWithException:] + 165
3 Foundation 0x00000001150479ab -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 384
4 Foundation 0x00000001150e2eb0 _decodeObjectBinary + 646
5 Foundation 0x00000001150e5662 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1752
6 Foundation 0x00000001150273ad -[NSArray(NSArray) initWithCoder:] + 161
7 Foundation 0x00000001150e3898 _decodeObjectBinary + 3182
8 Foundation 0x00000001150e22d2 _decodeObject + 163
9 Foundation 0x00000001150e21b2 -[NSKeyedUnarchiver decodeObjectForKey:] + 162
10 Foundation 0x00000001150e1110 +[NSKeyedUnarchiver unarchiveObjectWithData:] + 79
11 MyApp.iOS 0x0000000104de107b -[MSDeviceTracker init] + 177
12 MyApp.iOS 0x0000000104de0f59 __33+[MSDeviceTracker sharedInstance]_block_invoke + 41
13 libdispatch.dylib 0x000000011ac57a3a _dispatch_client_callout + 8
14 libdispatch.dylib 0x000000011ac58db3 _dispatch_once_callout + 20
15 MyApp.iOS 0x0000000104de0f2d +[MSDeviceTracker sharedInstance] + 45
16 MyApp.iOS 0x0000000104dd0d22 +[MSAppCenter setWrapperSdk:] + 56
17 MyApp.iOS 0x0000000105362a69 xamarin_dyn_objc_msgSend + 217
18 ??? 0x000000015c3c67ec 0x0 + 5842429932
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/Frameworks/i/Versions/16.1.1.27/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:460
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/runtime/Delegates.generated.cs:398
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
at (wrapper managed-to-native) ApiDefinition.Messaging.void_objc_msgSend_IntPtr(intptr,intptr,intptr)
at Microsoft.AppCenter.iOS.Bindings.MSAppCenter.SetWrapperSdk (Microsoft.AppCenter.iOS.Bindings.MSWrapperSdk wrapperSdk) [0x00023] in <d384bd2ae92b44008630788986ca7bdf>:0
at Microsoft.AppCenter.AppCenter.SetWrapperSdk () [0x00017] in <df2ccd8a0b774ab79c869a1d3fbc3ad1>:0
at Microsoft.AppCenter.AppCenter.PlatformStart (System.String appSecret, System.Type[] services) [0x00000] in <df2ccd8a0b774ab79c869a1d3fbc3ad1>:0
at Microsoft.AppCenter.AppCenter.Start (System.String appSecret, System.Type[] services) [0x00000] in <df2ccd8a0b774ab79c869a1d3fbc3ad1>:0
at MyApp.App.OnStart () [0x00006] in /Users/username/Documents/GitHub/MyApp/MyApp/App.xaml.cs:112
at Xamarin.Forms.Application.SendStart () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Application.cs:346
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDictionary launchOptions) [0x00036] in D:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:58
at MyApp.iOS.Core.AppDelegate.FinishedLaunching (UIKit.UIApplication nativeApp, Foundation.NSDictionary options) [0x000e4] in /Users/username/Documents/GitHub/MyApp/iOS/Core/AppDelegate.cs:100
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.1.1.27/src/Xamarin.iOS/UIKit/UIApplication.cs:57
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.1.1.27/src/Xamarin.iOS/UIKit/UIApplication.cs:92
at MyApp.iOS.Application.Main (System.String[] args) [0x00000] in /Users/username/Documents/GitHub/MyApp/iOS/Main.cs:13
I tried to skip linking Microsoft.AppCenter but it did not help

debugserver quits unexpectedly every time I run a program in Xcode

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: debugserver [1466]
Path: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver
Identifier: com.apple.dt.Xcode
Version: 12.5.1 (18212)
Build Info: IDEFrameworks-18212000000000000~4 (12E507)
App Item ID: 497799835
App External ID: 842555601
Code Type: ARM-64 (Native)
Parent Process: lldb-rpc-server [1301]
Responsible: Xcode [1287]
User ID: 501
Date/Time: 2021-07-16 10:48:03.3698 -0400
OS Version: macOS 12.0 (21A5268h)
Report Version: 12
Anonymous UUID: F27B101C-8068-145E-293D-A7AF546FA99A
Time Awake Since Boot: 1100 seconds
System Integrity Protection: enabled
Crashed Thread: 0 main thread Dispatch queue: com.apple.main-thread
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000019287c4e0
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [1466]
External Modification Warnings:
Process used task_for_pid().
Application Specific Information:
Thread 0 Crashed:: main thread Dispatch queue: com.apple.main-thread
0 libc++.1.dylib 0x19287c4e0 std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) + 60
1 debugserver 0x10048a464 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) + 56
2 debugserver 0x10048a464 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) + 56
3 debugserver 0x100482a8c RNBRemote::SendStopReplyPacketForThread(unsigned long long) + 308
4 debugserver 0x100471b48 RNBRemote::HandlePacket_last_signal(char const*) + 140
5 debugserver 0x10047314c RNBRemote::HandlePacket_v(char const*) + 1792
6 debugserver 0x100481500 RNBRemote::HandleReceivedPacket(RNBRemote::PacketEnum*) + 356
7 debugserver 0x1004592c4 RNBRunLoopGetStartModeFromRemote(RNBRemote*) + 184
8 debugserver 0x10045b6b8 main + 4652
9 dyld 0x100c250fc start + 520
Thread 1:: read gdb-remote packets thread
0 libsystem_kernel.dylib 0x1928da504 read + 8
1 debugserver 0x10048d468 RNBSocket::Read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 96
2 debugserver 0x100481c5c RNBRemote::ThreadFunctionReadRemoteData(void*) + 196
3 libsystem_pthread.dylib 0x19291543c _pthread_start + 148
4 libsystem_pthread.dylib 0x1929100d4 thread_start + 8
Thread 2:: exception monitoring thread
0 libsystem_kernel.dylib 0x1928d9914 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1928d9cc4 mach_msg + 76
2 debugserver 0x100491430 MachException::Message::Receive(unsigned int, int, unsigned int, unsigned int) + 188
3 debugserver 0x10049c6b4 MachTask::ExceptionThread(void*) + 288
4 libsystem_pthread.dylib 0x19291543c _pthread_start + 148
5 libsystem_pthread.dylib 0x1929100d4 thread_start + 8
Thread 3:: kqueue thread
0 libsystem_kernel.dylib 0x1928df8b0 kevent + 8
1 debugserver 0x10045d844 kqueue_thread(void*) + 152
2 libsystem_pthread.dylib 0x19291543c _pthread_start + 148
3 libsystem_pthread.dylib 0x1929100d4 thread_start + 8
Thread 4:: child process status watcher thread
0 libsystem_kernel.dylib 0x1928dd0a4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x192915a14 _pthread_cond_wait + 1240
2 debugserver 0x100468c40 PThreadEvent::WaitForSetEvents(unsigned int, timespec const*) const + 60
3 debugserver 0x10045eb1c DNBProcessWaitForEvents(int, unsigned int, bool, timespec*) + 76
4 debugserver 0x100469890 RNBContext::ThreadFunctionProcessStatus(void*) + 232
5 libsystem_pthread.dylib 0x19291543c _pthread_start + 148
6 libsystem_pthread.dylib 0x1929100d4 thread_start + 8
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x000000016f9a9ea8 x1: 0x000000016f9aa0b8 x2: 0x0000000000000001 x3: 0x000000016f9aa1f1
x4: 0x0000000000000000 x5: 0x000000016f9a9e30 x6: 0x0000000000000029 x7: 0x000000000000003e
x8: 0x0000000000000054 x9: 0x00278001004c53f0 x10: 0x0000000000000002 x11: 0x0000000000000008
x12: 0x0000000000000000 x13: 0x0000000000000000 x14: 0x0000000000000010 x15: 0x0000000000000002
x16: 0x00200001004c5320 x17: 0x00000001004c5320 x18: 0x0000000000000000 x19: 0x000000016f9a9ea8
x20: 0x000000016f9a9f88 x21: 0x0000000000000001 x22: 0x00000001004b0168 x23: 0x0000000000000000
x24: 0x00000000000070da x25: 0x0000000000000020 x26: 0x00000001004b0147 x27: 0x00000000000000a0
x28: 0x00000000000005b9 fp: 0x000000016f9a9e90 lr: 0x3c5c00010048a464
sp: 0x000000016f9a9e80 pc: 0x000000019287c4e0 cpsr: 0x20000000
far: 0x000000016fbd7000 esr: 0xf200c472 (Breakpoint) pointer authentication trap DA
Binary Images:
0x192857000 - 0x1928c0fff libc++.1.dylib (*) <e5324efb-096c-37bb-ba81-af1cb5162ea2> /usr/lib/libc++.1.dylib
0x100454000 - 0x1004c3fff com.apple.dt.Xcode (12.5.1) <3bdecb4d-7b7e-36b4-ab9a-18b785711d97> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver
0x100c20000 - 0x100c7bfff dyld (*) <d453e645-e157-37a2-8520-9da57a0c71f3> /usr/lib/dyld
0x1928d8000 - 0x19290dfff libsystem_kernel.dylib (*) <56136a5e-cfc9-3fc9-8617-e3941f393c78> /usr/lib/system/libsystem_kernel.dylib
0x19290e000 - 0x19291afff libsystem_pthread.dylib (*) <9891d5d0-65ec-33af-9bc0-4fd70f166924> /usr/lib/system/libsystem_pthread.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 1
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 14
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=623.1M resident=0K(0%) swapped_out_or_unallocated=623.1M(100%)
Writable regions: Total=557.5M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=557.5M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Activity Tracing 256K 1
Kernel Alloc Once 32K 1
MALLOC 163.2M 16
MALLOC guard page 96K 5
MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)
STACK GUARD 56.1M 5
Stack 10.1M 5
VM_ALLOCATE 1.0G 1
__AUTH 214K 47
__AUTH_CONST 2882K 125
__DATA 5018K 117
__DATA_CONST 3224K 127
__DATA_DIRTY 233K 55
__LINKEDIT 545.4M 4
__OBJC_CONST 260K 30
__OBJC_RO 80.8M 1
__OBJC_RW 2976K 1
__TEXT 77.7M 133
__UNICODE 588K 1
dyld private memory 1024K 1
mapped file 48K 1
shared memory 64K 4
=========== ======= =======
TOTAL 2.3G 682
TOTAL, minus reserved VM space 1.9G 682
-----------
Full Report
-----------
{"app_name":"debugserver","timestamp":"2021-07-16 10:48:03.00 -0400","app_version":"12.5.1","slice_uuid":"3bdecb4d-7b7e-36b4-ab9a-18b785711d97","adam_id":"497799835","build_version":"18212","platform":1,"bundleID":"com.apple.dt.Xcode","share_with_app_devs":1,"is_first_party":0,"etl_key":"3","bug_type":"309","os_version":"macOS 12.0 (21A5268h)","incident_id":"2AB95BAF-3CF3-4FDC-9CA6-E40F7FCE6EA0","name":"debugserver"}
{
"uptime" : 1100,
"procLaunch" : "2021-07-16 10:48:03.0921 -0400",
"procRole" : "Unspecified",
"version" : 2,
"userID" : 501,
"deployVersion" : 209,
"modelCode" : "MacBookAir10,1",
"coalitionID" : 932,
"osVersion" : {
"train" : "macOS 12.0",
"build" : "21A5268h",
"releaseType" : "User"
},
"captureTime" : "2021-07-16 10:48:03.3698 -0400",
"incident" : "2AB95BAF-3CF3-4FDC-9CA6-E40F7FCE6EA0",
"pid" : 1466,
"translated" : false,
"cpuType" : "ARM-64",
"procName" : "debugserver",
"procPath" : "\/Applications\/Xcode.app\/Contents\/SharedFrameworks\/LLDB.framework\/Versions\/A\/Resources\/debugserver",
"bundleInfo" : {"CFBundleShortVersionString":"12.5.1","CFBundleVersion":"18212","CFBundleIdentifier":"com.apple.dt.Xcode"},
"buildInfo" : {"ProjectName":"IDEFrameworks","SourceVersion":"18212000000000000","ProductBuildVersion":"12E507","BuildVersion":"4"},
"storeInfo" : {"storeCohortMetadata":"7|date=1626399000000&sf=143441&pgtp=Search&pgid=osx&prpg=Genre_182860&ctxt=Search&issrch=1&imptyp=card&kind=macSoftware&lngid=1","itemID":"497799835","deviceIdentifierForVendor":"3CB280EC-A61D-51EE-9331-BFE200816C16","thirdParty":true,"softwareVersionExternalIdentifier":"842555601"},
"parentProc" : "lldb-rpc-server",
"parentPid" : 1301,
"coalitionName" : "com.apple.dt.Xcode",
"crashReporterKey" : "F27B101C-8068-145E-293D-A7AF546FA99A",
"responsiblePid" : 1287,
"responsibleProc" : "Xcode",
"sip" : "enabled",
"isCorpse" : 1,
"exception" : {"codes":"0x0000000000000001, 0x000000019287c4e0","rawCodes":[1,6753338592],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
"termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":1466},
"asi" : {"dyld":[]},
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":1},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":14},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":1},
"faultingThread" : 0,
"threads" : [{"triggered":true,"id":28904,"threadState":{"x":[{"value":6167371432},{"value":6167371960},{"value":1},{"value":6167372273},{"value":0},{"value":6167371312},{"value":41},{"value":62},{"value":84},{"value":11118265880040432,"symbolLocation":11118261580070928,"symbol":"vtable for std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >"},{"value":2},{"value":8},{"value":0},{"value":0},{"value":16},{"value":2},{"value":9007203554710304,"symbolLocation":9007199254741016,"symbol":"vtable for std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >"},{"value":4299969312,"symbolLocation":24,"symbol":"vtable for std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >"},{"value":0},{"value":6167371432},{"value":6167371656},{"value":1},{"value":4299882856},{"value":0},{"value":28890},{"value":32},{"value":4299882823},{"value":160},{"value":1465}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4349351344432784484},"cpsr":{"value":536870912},"fp":{"value":6167371408},"sp":{"value":6167371392},"esr":{"value":4060136562,"description":"(Breakpoint) pointer authentication trap DA"},"pc":{"value":6753338592,"matchesCrashFrame":1},"far":{"value":6169653248}},"name":"main thread","queue":"com.apple.main-thread","frames":[{"imageOffset":152800,"symbol":"std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)","symbolLocation":60,"imageIndex":0},{"imageOffset":222308,"symbol":"std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long)","symbolLocation":56,"imageIndex":1},{"imageOffset":222308,"symbol":"std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long)","symbolLocation":56,"imageIndex":1},{"imageOffset":191116,"symbol":"RNBRemote::SendStopReplyPacketForThread(unsigned long long)","symbolLocation":308,"imageIndex":1},{"imageOffset":121672,"symbol":"RNBRemote::HandlePacket_last_signal(char const*)","symbolLocation":140,"imageIndex":1},{"imageOffset":127308,"symbol":"RNBRemote::HandlePacket_v(char const*)","symbolLocation":1792,"imageIndex":1},{"imageOffset":185600,"symbol":"RNBRemote::HandleReceivedPacket(RNBRemote::PacketEnum*)","symbolLocation":356,"imageIndex":1},{"imageOffset":21188,"symbol":"RNBRunLoopGetStartModeFromRemote(RNBRemote*)","symbolLocation":184,"imageIndex":1},{"imageOffset":30392,"symbol":"main","symbolLocation":4652,"imageIndex":1},{"imageOffset":20732,"symbol":"start","symbolLocation":520,"imageIndex":2}]},{"id":28906,"name":"read gdb-remote packets thread","frames":[{"imageOffset":9476,"symbol":"read","symbolLocation":8,"imageIndex":3},{"imageOffset":234600,"symbol":"RNBSocket::Read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)","symbolLocation":96,"imageIndex":1},{"imageOffset":187484,"symbol":"RNBRemote::ThreadFunctionReadRemoteData(void*)","symbolLocation":196,"imageIndex":1},{"imageOffset":29756,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":4},{"imageOffset":8404,"symbol":"thread_start","symbolLocation":8,"imageIndex":4}]},{"id":28908,"name":"exception monitoring thread","frames":[{"imageOffset":6420,"symbol":"mach_msg_trap","symbolLocation":8,"imageIndex":3},{"imageOffset":7364,"symbol":"mach_msg","symbolLocation":76,"imageIndex":3},{"imageOffset":250928,"symbol":"MachException::Message::Receive(unsigned int, int, unsigned int, unsigned int)","symbolLocation":188,"imageIndex":1},{"imageOffset":296628,"symbol":"MachTask::ExceptionThread(void*)","symbolLocation":288,"imageIndex":1},{"imageOffset":29756,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":4},{"imageOffset":8404,"symbol":"thread_start","symbolLocation":8,"imageIndex":4}]},{"id":28913,"name":"kqueue thread","frames":[{"imageOffset":30896,"symbol":"kevent","symbolLocation":8,"imageIndex":3},{"imageOffset":38980,"symbol":"kqueue_thread(void*)","symbolLocation":152,"imageIndex":1},{"imageOffset":29756,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":4},{"imageOffset":8404,"symbol":"thread_start","symbolLocation":8,"imageIndex":4}]},{"id":28914,"name":"child process status watcher thread","frames":[{"imageOffset":20644,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":3},{"imageOffset":31252,"symbol":"_pthread_cond_wait","symbolLocation":1240,"imageIndex":4},{"imageOffset":85056,"symbol":"PThreadEvent::WaitForSetEvents(unsigned int, timespec const*) const","symbolLocation":60,"imageIndex":1},{"imageOffset":43804,"symbol":"DNBProcessWaitForEvents(int, unsigned int, bool, timespec*)","symbolLocation":76,"imageIndex":1},{"imageOffset":88208,"symbol":"RNBContext::ThreadFunctionProcessStatus(void*)","symbolLocation":232,"imageIndex":1},{"imageOffset":29756,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":4},{"imageOffset":8404,"symbol":"thread_start","symbolLocation":8,"imageIndex":4}]}],
"usedImages" : [
{
"source" : "P",
"arch" : "arm64e",
"base" : 6753185792,
"size" : 434176,
"uuid" : "e5324efb-096c-37bb-ba81-af1cb5162ea2",
"path" : "\/usr\/lib\/libc++.1.dylib",
"name" : "libc++.1.dylib"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 4299505664,
"CFBundleShortVersionString" : "12.5.1",
"CFBundleIdentifier" : "com.apple.dt.Xcode",
"size" : 458752,
"uuid" : "3bdecb4d-7b7e-36b4-ab9a-18b785711d97",
"path" : "\/Applications\/Xcode.app\/Contents\/SharedFrameworks\/LLDB.framework\/Versions\/A\/Resources\/debugserver",
"name" : "debugserver",
"CFBundleVersion" : "18212"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 4307681280,
"size" : 376832,
"uuid" : "d453e645-e157-37a2-8520-9da57a0c71f3",
"path" : "\/usr\/lib\/dyld",
"name" : "dyld"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6753714176,
"size" : 221184,
"uuid" : "56136a5e-cfc9-3fc9-8617-e3941f393c78",
"path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
"name" : "libsystem_kernel.dylib"
},
{
"source" : "P",
"arch" : "arm64e",
"base" : 6753935360,
"size" : 53248,
"uuid" : "9891d5d0-65ec-33af-9bc0-4fd70f166924",
"path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
"name" : "libsystem_pthread.dylib"
}
],
"vmSummary" : "ReadOnly portion of Libraries: Total=623.1M resident=0K(0%) swapped_out_or_unallocated=623.1M(100%)\nWritable regions: Total=557.5M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=557.5M(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nKernel Alloc Once 32K 1 \nMALLOC 163.2M 16 \nMALLOC guard page 96K 5 \nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nSTACK GUARD 56.1M 5 \nStack 10.1M 5 \nVM_ALLOCATE 1.0G 1 \n__AUTH 214K 47 \n__AUTH_CONST 2882K 125 \n__DATA 5018K 117 \n__DATA_CONST 3224K 127 \n__DATA_DIRTY 233K 55 \n__LINKEDIT 545.4M 4 \n__OBJC_CONST 260K 30 \n__OBJC_RO 80.8M 1 \n__OBJC_RW 2976K 1 \n__TEXT 77.7M 133 \n__UNICODE 588K 1 \ndyld private memory 1024K 1 \nmapped file 48K 1 \nshared memory 64K 4 \n=========== ======= ======= \nTOTAL 2.3G 682 \nTOTAL, minus reserved VM space 1.9G 682 \n",
"legacyInfo" : {
"threadTriggered" : {
"name" : "main thread",
"queue" : "com.apple.main-thread"
}
},
"trialInfo" : {
"rollouts" : [
{
"rolloutId" : "607844aa04477260f58a8077",
"factorPackIds" : {
"SIRI_MORPHUN_ASSETS" : "60c88ac7e7d17206e1f95943"
},
"deploymentId" : 250000055
},
{
"rolloutId" : "601d9415f79519000ccd4b69",
"factorPackIds" : {
"SIRI_TEXT_TO_SPEECH" : "60ca460c10d03d047ed95dfe"
},
"deploymentId" : 250000099
},
{
"rolloutId" : "5fc94383418129005b4e9ae0",
"factorPackIds" : {
},
"deploymentId" : 250000092
},
{
"rolloutId" : "602ad4dac86151000cf27e46",
"factorPackIds" : {
"SIRI_DICTATION_ASSETS" : "60c8a862e7d17206e1f95953"
},
"deploymentId" : 250000122
}
],
"experiments" : [
]
}
}
Model: MacBookAir10,1, BootROM 7429.0.133.121.1, proc 8:4:4 processors, 8 GB, SMC
Graphics: kHW_AppleM1Item, Apple M1, spdisplays_builtin
Memory Module: LPDDR4
AirPort: spairport_wireless_card_type_wifi, wl0: May 11 2021 22:21:31 version 18.20.284.1.7.8.108 FWID 01-9dd86976
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.1 Bus
USB Device: USB 3.1 Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.
I'm still learning Swift and Xcode, so I'm not sure what else is needed. If anything else is, please let me know, and I will edit this question.
The code I am running is the default playground code, where UIKit is imported, and a single variable is declared. I have tried uninstalling and reinstalling Xcode. I am also running the Monterey beta, so that may be causing the issue. My Xcode version is Xcode 12.5.1.
Any help is greatly appreciated!

DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./foo/my.dylib ./bar/exec returns 1 w/o running my executable

On macOS 10.12.6, I have a shared library and an executable (both built myself, SIP should not apply AFAIK) and I'd like to preload the library for the executable. It fails, with a return code of 1, and silently otherwise:
$ ./bar/exec
<does stuff>
$ DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./foo/my.dylib ./bar/exec
<returns immediately>
$ echo $?
1
# 1 is not an explicitly returned value from ./bar/exec
If I add either DYLD_PRINT_LIBRARIES or DYLD_PRINT_LIBRARIES_POST_LAUNCH options as documented in man dyld, they both show that both the library and the executable have been loaded successfully:
...
dyld: loaded: /full/path/to/exec
dyld: loaded: ./foo/my.dylib
...
If I try to run the executable with preload in either dtruss or lldb, it runs, without the library preloaded. This might make sense because these tools are SIP-protected.
How do I go about debugging this?
UPDATE
Thanks to #macmoonshine, I am able to reproduce the return code 1 exit under lldb by setting the preload environment from LLDB itself as opposed for LLDB:
(lldb) env DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./foo/my.dylib
(lldb) run
...
Process 24130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x00007fffc8aac310 libsystem_kernel.dylib`__exit
...
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
* frame #0: 0x00007fffc8aac310 libsystem_kernel.dylib`__exit
frame #1: 0x000000010008ebac my.dylib`my_init at my.c:86 [opt]
frame #2: 0x0000000100018a1b dyld`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 385
frame #3: 0x0000000100018c1e dyld`ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
frame #4: 0x00000001000144aa dyld`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 338
frame #5: 0x0000000100013524 dyld`ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 138
frame #6: 0x00000001000135b9 dyld`ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 75
frame #7: 0x0000000100005434 dyld`dyld::initializeMainExecutable() + 125
frame #8: 0x00000001000098c6 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 3966
frame #9: 0x0000000100004249 dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 470
frame #10: 0x0000000100004036 dyld`_dyld_start + 54
This is a start for debugging.
You can run your code in lldb, where you can set the environment with the env command:
env DYLD_FORCE_FLAT_NAMESPACE=1
env DYLD_INSERT_LIBRARIES=./foo/my.dylib
run
With lldb you can run your program until it crashes. If it exists abnormally with exit() (or _exit()), you should set symbolic breakpoints with b exitand b _exit. So you have the chance to get a backtrace where it fails.

Can an EXEC_BAD_INSTRUCTION (SIGILL) on dyld my fault?

I'm developing this app that worked beautifully on dev box and test box alike with osx 10.8.
Test box is significantly older hardware but same software setup as dev box.
Dev Box: intel core i7
Test Box: intel core 2 duo
Upon upgrade to OSX 10.9 Mavericks on both machines, I'm getting an EXEC_BAD_INSTRUCTION(SIGILL) failure on my test box with an error report that seems to suggest a problem with 10.9.
Is it possible that it's something I did or should I nag Apple to fix their Os?
I have tried all the DYLD_PRINT_* env variables to see if I get some clues, but it just fails with no abnormal or indicative messages.
Any Ideas as to what It could be or where to look further/deeper?
Your interpretation of this trace is also welcome.
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Application Specific Information:
/Volumes/juan/Library/Developer/Xcode/DerivedData/****/Contents/MacOS/../Frameworks/libprotobuf-lite.8.dylib
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libprotobuf-lite.8.dylib 0x0000000103d18bc4 _GLOBAL__I_a + 4
1 dyld 0x00007fff69423c2e ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 268
2 dyld 0x00007fff69423dba ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
3 dyld 0x00007fff69420a62 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) + 308
4 dyld 0x00007fff694209eb ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) + 189
5 dyld 0x00007fff694208f6 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 54
6 dyld 0x00007fff694141da dyld::initializeMainExecutable() + 189
7 dyld 0x00007fff69417560 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2419
8 dyld 0x00007fff6941327b dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 477
9 dyld 0x00007fff6941305e _dyld_start + 54
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000001 rbx: 0x0000000103d18bc0 rcx: 0x00007fff5c425cd0 rdx: 0x00007fff5c425c78
rdi: 0x0000000000000001 rsi: 0x00007fff5c425c68 rbp: 0x00007fff5c4240c0 rsp: 0x00007fff5c4240c0
r8: 0x00007fff69446178 r9: 0x00007fff5c424000 r10: 0x00007fff9abcbc70 r11: 0x00007fff961c02aa
r12: 0x0000000000000000 r13: 0x00007fff694460b0 r14: 0x00007fff6944eb28 r15: 0x0000000103d20310
rip: 0x0000000103d18bc4 rfl: 0x0000000000010246 cr2: 0x0000000103d18bc0
Logical CPU: 1
Error Code: 0x00000000
Trap Number: 6
So I found the problem.
My libraries were built using homebrew. By default homebrew optimizes for native architecture, resulting in machine instructions that don't work on older machines.
to prevent brew from building processsor-speciffic optimisations you must
brew install --build-bottle protobuf ( or your specific lib )

Adding DTPerformanceSession.framework causes app to crash on run

I added DTPerformanceSession.framework to the OSX app Build Phases and when I run the app it crashes with the following error:
dyld`dyld_fatal_error:
0x7fff5fc0109c: int3
0x7fff5fc0109d: nop
Console message:
dyld: Library not loaded: #rpath/DTPerformanceSession.framework/Versions/A/DTPerformanceSession
Referenced from: /Users/Danger/Library/Developer/Xcode/DerivedData/HSCountingInputStream-dbhgckaaqtaiqueimpvpxllvygvt/Build/Products/Debug/HSCountingInputStream
Reason: image not found
Back trace:
* thread #1: tid = 0x5e40d, 0x00007fff5fc0109d dyld`dyld_fatal_error + 1, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x00007fff5fc0109d dyld`dyld_fatal_error + 1
frame #1: 0x00007fff5fc02138 dyld`dyld::halt(char const*) + 79
frame #2: 0x00007fff5fc059bd dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2733
frame #3: 0x00007fff5fc01397 dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 761
frame #4: 0x00007fff5fc0105e dyld`_dyld_start + 54
Note: DTPerformanceSession.framework is at path:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks
See the great page: Using code generated flags to debug with Instruments. Basically one just needs to add the framework, build and remove the framework, it is needed only for Xcode to find the include and only once. Alternatively add the framework and mark it "Optional".

Resources