Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从NSLog中分离故障?_Ios_Objective C_Iphone_Crash_Segmentation Fault - Fatal编程技术网

Ios 从NSLog中分离故障?

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

我在使用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 _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
    是什么意思
  • 我如何才能找出这是否是由坏内存问题引起的
  • asl文件在多个线程下是否发生故障
  • 我应该如何调试它

  • 任何帮助都将不胜感激!谢谢

    你说缓冲区是字符缓冲区。如果是这种情况,您应该像这样初始化字符串

    NSString*截断=[[NSString alloc]initWithBytes:缓冲区 长度:len NSUTF8StringEncoding]


    其中len是缓冲区中字符的长度。

    缓冲区可能无效,例如,不是UTF8。