应用程序崩溃在我的设备上,但在模拟器和通过xcode调试时工作正常

时间:2013-10-17 12:01:38

标签: iphone ios objective-c xcode amazon-s3

当我尝试在IOS6设备上运行时,我的应用程序崩溃了..但它在模拟器中工作正常,通过xcode进行调试,它也可以在IOS 7设备中顺利运行..问题仅适用于IOS 6设备。这是我的控制台历史

<Error>: *** Terminating app due to uncaught exception'NSFileHandleOperationException', 
 reason: '*** -[NSConcreteFileHandle writeData:]: Bad file descriptor'
-iPhone ReportCrash[5485]
   <Notice>: Formulating crash report for process [5482]
   (UIKitApplication:[0x7046][5482])
    <Warning>: (UIKitApplication:[0x7046]) Jobappears to have crashed: Abort trap:    6

     <Warning>: Application 'UIKitApplication:[0x7046]'  
    exited abnormally with signal 6: Abort trap: 6

这是我的设备日志历史......

Incident Identifier: C7947F65-AD9A-4C9A-9A64-B9E3CF3C3003
CrashReporter Key:   b5b0efe726413c3f18049e973c20792dc187d12e
Hardware Model:      iPhone5,1
Process:         PhytterDock [6121]
  Path:            /var/mobile/Applications/FEB77102-11A1-4A8B-8700-  C2EE2C3E9289/PhytterDock.app/PhytterDock
Identifier:      PhytterDock
Version:         ??? (???)
Code Type:       ARM (Native)
            0x3991295e objc_exception_throw + 26
    0x39d7cfb2 pthread_kill + 54
2   libsystem_c.dylib               0x39db9366 abort + 90
3   libc++abi.dylib                 0x39361dda abort_message + 70
4   libc++abi.dylib                 0x3935f094 default_terminate() + 20
5   libobjc.A.dylib                 0x39912a58 _objc_terminate() + 144
6   libc++abi.dylib                 0x3935f118 safe_handler_caller(void (*)()) + 76
7   libc++abi.dylib                 0x3935f1b0 std::terminate() + 16
8   libc++abi.dylib                 0x39360626 __cxa_rethrow + 90
9   libobjc.A.dylib                 0x399129b0 objc_exception_rethrow + 8
10  CoreFoundation                  0x31b5e29c CFRunLoopRunSpecific + 452
11  CoreFoundation                  0x31b5e0c4 CFRunLoopRunInMode + 100
12  GraphicsServices                0x3573d336 GSEventRunModal + 70
13  UIKit                           0x33a7a2b4 UIApplicationMain + 1116
14  PhytterDock                     0x000cf6d4 main (main.m:15)
15  libdyld.dylib                   0x39d3fb1c start + 0

 Thread 1:
  0   libsystem_kernel.dylib            0x39e06d98 __workq_kernreturn + 8
 1   libsystem_c.dylib              0x39d54ad6 _pthread_workq_return + 14
 2   libsystem_c.dylib              0x39d547f2 _pthread_wqthread + 362
 3   libsystem_c.dylib              0x39d54680 start_wqthread + 4

 Thread 2 name:  Dispatch queue: com.apple.libdispatch-manager
 Thread 2:
0   libsystem_kernel.dylib          0x39df65d0 kevent64 + 24
1   libdispatch.dylib               0x39d31d22 _dispatch_mgr_invoke + 806
2   libdispatch.dylib               0x39d2d374 _dispatch_mgr_thread + 32

Thread 3 name:  WebThread
 Thread 3:
  0   libsystem_kernel.dylib            0x39df5e30 mach_msg_trap + 20
  1   libsystem_kernel.dylib            0x39df5fd0 mach_msg + 48
  2   CoreFoundation                    0x31bec2b6 __CFRunLoopServiceMachPort + 126
  3   CoreFoundation                    0x31beb02c __CFRunLoopRun + 900
  4   CoreFoundation                    0x31b5e238 CFRunLoopRunSpecific + 352
  5   CoreFoundation                    0x31b5e0c4 CFRunLoopRunInMode + 100
  6   WebCore                           0x37b66390 RunWebThread(void*) + 440
  7   libsystem_c.dylib                 0x39d5f0de _pthread_start + 306
  8   libsystem_c.dylib                 0x39d5efa4 thread_start + 4

 Thread 4:
 0   libsystem_kernel.dylib         0x39e06d98 __workq_kernreturn + 8
 1   libsystem_c.dylib              0x39d54ad6 _pthread_workq_return + 14
 2   libsystem_c.dylib              0x39d547f2 _pthread_wqthread + 362
 3   libsystem_c.dylib              0x39d54680 start_wqthread + 4

 Thread 5 name:  com.apple.NSURLConnectionLoader
 Thread 5:
  0   libsystem_kernel.dylib            0x39df5e30 mach_msg_trap + 20
  1   libsystem_kernel.dylib            0x39df5fd0 mach_msg + 48
  2   CoreFoundation                    0x31bec2b6 __CFRunLoopServiceMachPort + 126
  3   CoreFoundation                    0x31beb02c __CFRunLoopRun + 900
  4   CoreFoundation                    0x31b5e238 CFRunLoopRunSpecific + 352
  5   CoreFoundation                    0x31b5e0c4 CFRunLoopRunInMode + 100
  6   Foundation                        0x324ab888 +[NSURLConnection(Loader) _    resourceLoadLoop:] + 304
  7   Foundation                        0x3252f22c __NSThread__main__ + 968
  8   libsystem_c.dylib                 0x39d5f0de _pthread_start + 306
  9   libsystem_c.dylib                 0x39d5efa4 thread_start + 4

 Thread 6:
 0   libsystem_kernel.dylib         0x39e06d98 __workq_kernreturn + 8
 1   libsystem_c.dylib              0x39d54ad6 _pthread_workq_return + 14
 2   libsystem_c.dylib              0x39d547f2 _pthread_wqthread + 362
 3   libsystem_c.dylib              0x39d54680 start_wqthread + 4

Thread 7:
 0   libsystem_kernel.dylib         0x39e06d98 __workq_kernreturn + 8
 1   libsystem_c.dylib              0x39d54ad6 _pthread_workq_return + 14
 2   libsystem_c.dylib              0x39d547f2 _pthread_wqthread + 362
 3   libsystem_c.dylib              0x39d54680 start_wqthread + 4

Thread 8 name:  com.apple.CFSocket.private
Thread 8:
0   libsystem_kernel.dylib          0x39e06594 __select + 20
1   CoreFoundation                  0x31bf0474 __CFSocketManager + 676
2   libsystem_c.dylib               0x39d5f0de _pthread_start + 306
3   libsystem_c.dylib               0x39d5efa4 thread_start + 4

Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x3b8c8524
r4: 0x00000006    r5: 0x3b8c8b78      r6: 0x1ed7ea14      r7: 0x2fd32a04
r8: 0x1ed7e9f0    r9: 0x00000888     r10: 0xffffffff     r11: 0x00000004
ip: 0x00000148    sp: 0x2fd329f8      lr: 0x39d7cfb7      pc: 0x39e06350
 cpsr: 0x00000010

2 个答案:

答案 0 :(得分:2)

我不确定为什么ios6具体是因为崩溃的原因就在那里

  

* - [NSConcreteFileHandle writeData:]:错误的文件描述符

我认为你没有以正确的模式打开文件(即启用写入),或者描述符本身无效。可能有很多原因,但这看起来不像操作系统特定的问题,除非你做了一些奇怪的事情。

您可以通过man 2 open

了解更多相关信息

答案 1 :(得分:0)

在iOS6下是NSFileHandle问题。 即使在空项目中,您也可以轻松地在iOS6下使用这个简单的代码进行崩溃:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardError];
    NSData *data = [@"testMessage\n" dataUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"before:%@", fileHandle);
    [fileHandle writeData:data];
    NSLog(@"after:%@", fileHandle);
    return YES;
}

在任何iOS下通过Xcode进行调试时,此代码可在模拟器和设备上正常运行。 但是,如果您在iOS6下运行没有Xcode的应用程序,只需点击设备上的应用程序图标,此应用程序崩溃时会显示您在该行中描述的相同错误消息:

[fileHandle writeData:data];

如果在iOS6下未附加Xcode进行调试,则看起来stdout和stderr管道已损坏。

我在iOS 6.1.3下检查了这个。

在我的情况下,应用程序使用仅在调试中使用的LogWriter,并且未在发布中使用。 所以,我建议在这种情况下使用try / catch。它允许您在iOS6下的设备上运行调试版本而不会崩溃:

@try
{
    [fileHandle writeData:data];
}
@catch (NSException *e)
{
    NSLog(@"NSException:%@", e);
}