Ios 从NSLog中分离故障?
我在使用NSLog时看到了一个segfault,特别是在64位设备上,带有Ios 从NSLog中分离故障?,ios,objective-c,iphone,crash,segmentation-fault,Ios,Objective C,Iphone,Crash,Segmentation Fault,我在使用NSLog时看到了一个segfault,特别是在64位设备上,带有SEGV\u ACCERR。我是iOS新手,所以我有点困惑 以下是堆栈跟踪: Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0x108074000 Crashed Thread: 0 Thread 0 Crashed: 0 libsystem_platform.dylib 0x00000001826ea31c _platfo
SEGV\u ACCERR
。我是iOS新手,所以我有点困惑
以下是堆栈跟踪:
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x108074000
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_platform.dylib 0x00000001826ea31c _platform_memmove + 300
1 libsystem_asl.dylib 0x00000001825289a4 asl_string_append_no_encoding_len + 92
2 libsystem_asl.dylib 0x0000000182522fc8 asl_string_new + 108
3 libsystem_asl.dylib 0x0000000182522df4 asl_msg_to_string_raw + 68
4 libsystem_asl.dylib 0x00000001825228dc _asl_send_message + 828
5 libsystem_asl.dylib 0x00000001825224fc asl_send + 8
6 CoreFoundation 0x0000000182a6fa1c __CFLogCString + 568
7 CoreFoundation 0x0000000182a6f7ac _CFLogvEx2 + 300
8 CoreFoundation 0x0000000182a6fc14 _CFLogvEx3 + 152
9 Foundation 0x0000000183435dd8 _NSLogv + 128
10 Foundation 0x000000018336ae04 NSLog + 28
以下是调用此函数的代码:
NSString *truncated = [NSString stringWithUTF8String:buffer];
// Using original NSLog to print.
#undef NSLog
NSLog(@"%@", truncated);
它在我的NSLog
调用中崩溃
其中,buffer
只是一个字符缓冲区
我的问题是:
NSLog
,甚至可能崩溃吗?还是我的堆栈跟踪错误SEG_ACCERR
是什么意思李>
任何帮助都将不胜感激!谢谢 你说缓冲区是字符缓冲区。如果是这种情况,您应该像这样初始化字符串 NSString*截断=[[NSString alloc]initWithBytes:缓冲区 长度:len NSUTF8StringEncoding]
其中len是缓冲区中字符的长度。缓冲区可能无效,例如,不是UTF8。