【发布时间】:2016-01-21 03:40:05
【问题描述】:
我看到使用 NSLog 时出现段错误,具体来说,它位于 64 位设备上,带有 SEGV_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 只是一个字符缓冲区。
我的问题具体是:
- 使用 Apple 提供的
NSLog是否可能导致崩溃?还是我的堆栈跟踪错误? -
SEG_ACCERR在这种情况下意味着什么? - 我如何才能确定这是否是由内存问题引起的?
- 多线程下的 asl 文件有问题吗?
- 我应该如何调试这个?
任何帮助将不胜感激!谢谢!
【问题讨论】:
-
可能是缓冲区无效,比如不是UTF8。
标签: ios objective-c iphone crash segmentation-fault