我有a little CLT用于复制和粘贴图像,用Objective-C ++编写。直到最近,这个程序按照预期编译和运行 - 但直到现在,它似乎已经开始在[NSApplication sharedApplication]
的调用中崩溃。
堆栈跟踪指示当NSApplication
初始化NSUserDefaults
实例时发生崩溃,最终调用CFDictionary
相关函数(即CFDictionarySetValue
)然后崩溃在free
...但是来自libjemalloc
。
这是一个示例堆栈跟踪:
- Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libjemalloc.2.dylib 0x000000010e7b4ec5 free + 164
1 libjemalloc.2.dylib 0x000000010e7e3d50 zone_free + 168
2 com.apple.CoreFoundation 0x00007fffc5a912c5 __CFBasicHashRehash + 3461
3 com.apple.CoreFoundation 0x00007fffc5a96927 __CFBasicHashAddValue + 103
4 com.apple.CoreFoundation 0x00007fffc5a97a3d CFDictionarySetValue + 221
5 com.apple.CoreFoundation 0x00007fffc5c467da __63-[_CFXPreferences(SearchListAdditions) withSnapshotSearchList:]_block_invoke + 554
6 com.apple.CoreFoundation 0x00007fffc5c4710f -[_CFXPreferences(SearchListAdditions) withSearchLists:] + 79
7 com.apple.CoreFoundation 0x00007fffc5c4655b -[_CFXPreferences(SearchListAdditions) withSnapshotSearchList:] + 155
8 com.apple.CoreFoundation 0x00007fffc5ad08bb __CFXPreferencesCopyCurrentApplicationState + 123
9 com.apple.CoreFoundation 0x00007fffc5ad04dc _CFLocaleCopyCurrentGuts + 268
10 com.apple.CoreFoundation 0x00007fffc5ad0399 +[NSLocale currentLocale] + 9
11 com.apple.Foundation 0x00007fffc7508026 -[NSUserDefaults(NSUserDefaults) init] + 1589
12 com.apple.Foundation 0x00007fffc7507995 +[NSUserDefaults(NSUserDefaults) standardUserDefaults] + 81
13 com.apple.AppKit 0x00007fffc35c9254 +[NSApplication initialize] + 90
14 libobjc.A.dylib 0x00007fffda9b0b04 CALLING_SOME_+initialize_METHOD + 19
15 libobjc.A.dylib 0x00007fffda9a16b9 _class_initialize + 579
16 libobjc.A.dylib 0x00007fffda9a105b lookUpImpOrForward + 240
17 libobjc.A.dylib 0x00007fffda9a0ad4 _objc_msgSend_uncached + 68
18 impaste 0x0000000106197198 void objc::run_thread<AXDryRunThread>(NSDictionary*) + 120
19 impaste 0x0000000106196820 main + 2608
20 libdyld.dylib 0x00007fffdb294235 start + 1
...最后一点是最好奇的,因为我没有使用JeMalloc库。我的CLT计划和the libraries on which it is built都与JeMalloc无关,the build system目前根本没有引用它。我不会在任何时候包含任何东西,或将任何东西链接到JeMalloc库。
但是:从堆栈跟踪看,我使用的CoreFoundation库看起来实际上是使用JeMalloc。
我对JeMalloc了解不多,但我相信它提供a global drop-in replacement for malloc
and free
(除了提供a host of custom, fine-grained memory-management functions)。
我对[NSApplication sharedApplication]
的调用(如上面的堆栈跟踪第18行所示)如下所示:
template <typename OCThreadType> inline
void run_thread(NSDictionary* options = @{}) {
@autoreleasepool {
[NSApplication sharedApplication];
[[[OCThreadType alloc] initWithOptions:options] start];
AXAppDelegate* delegate = [[AXAppDelegate alloc] init];
NSApp.delegate = delegate;
[NSApp run];
};
}
有人可以对此有所了解吗?什么可能导致这个程序以这种方式崩溃(具体来说,最近在CoreFoundation中可能发生了什么变化)?