Crash application après commande console répétée

  • Créateur du sujet Créateur du sujet Gz'
  • Date de début Date de début

Gz'

Membre actif
29 Mai 2007
761
43
38
Kuala Lumpur, Malaisie
www.ftpix.fr
Bonjour,

J'ai un petit soucis, je développe ma première application en obj-c/cocoa. Mais j'ai un petit soucis, elle crash tous les jours à ± la même heure. En gros je lance l'application le matin quand j'arrive au boulot et plante vers 17h.

L'application lance une commande console toutes les x minutes utilisant la méthode suivante:

Bloc de code:
- (NSString*) executeCommand: (NSString*)cmd: (NSArray*) args
{

	NSLog (@"CMD: %@ %@", cmd, [args componentsJoinedByString:@" "]);
	
	NSTask *task = [NSTask new];
	[task setLaunchPath:cmd];
	[task setArguments:args];
	
	NSPipe *pipe = [NSPipe pipe];
	[task setStandardOutput:pipe];
	
	[task launch];
		
	NSFileHandle *file;
        file = [pipe fileHandleForReading];
	
	NSData *data = [file readDataToEndOfFile];
	
	
	[task waitUntilExit];
	
	NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
	NSLog (@"RESULT: \n%@", string);
		
	return string;
}

Je débute en obj-c/cocoa donc il y a sûrement quelque chose qui m'échappe, si quelqu'un a une idée. L'application utilise le garbage collector.

Le crash log:

Bloc de code:
Process:         ProxySwitcher [10813]
Path:            /Applications/ProxySwitcher.app/Contents/MacOS/ProxySwitcher
Identifier:      com.ftpix.ProxySwitcher
Version:         1.0 (1.0)
Code Type:       X86-64 (Native)
Parent Process:  launchd [214]

Date/Time:       2012-03-05 13:47:15.645 +0800
OS Version:      Mac OS X 10.7.3 (11D50)
Report Version:  9

Crashed Thread:  2

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
objc[10813]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[NSConcreteFileHandle readDataOfLength:]: Bad file descriptor'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff8d84ffc6 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff85dbed5e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8d84fdfa +[NSException raise:format:arguments:] + 106
	3   CoreFoundation                      0x00007fff8d84fd84 +[NSException raise:format:] + 116
	4   Foundation                          0x00007fff88184fce _NSFileHandleRaiseOperationException + 130
	5   Foundation                          0x00007fff8812418a -[NSConcreteFileHandle readDataOfLength:] + 99
	6   Foundation                          0x00007fff88124125 -[NSConcreteFileHandle readDataToEndOfFile] + 25
	7   ProxySwitcher                       0x0000000109f107b0 -[CommandLine executeCommand::] + 400
	8   ProxySwitcher                       0x0000000109f109b2 -[CommandLine isProxyOn::] + 290
	9   ProxySwitcher                       0x0000000109f10db0 -[Proxy isOn:] + 112
	10  ProxySwitcher                       0x0000000109f11290 -[ProxyMenu isOn] + 64
	11  ProxySwitcher                       0x0000000109f11205 -[ProxyMenu initWithProxy:andParent:] + 261
	12  ProxySwitcher                       0x0000000109f0face -[ps_AppDelegate refreshMenu] + 798
	13  ProxySwitcher                       0x0000000109f1053b -[ps_AppDelegate backgroundRefreshInnerThread] + 43
	14  Foundation                          0x00007fff8811074e -[NSThread main] + 68
	15  Foundation                          0x00007fff881106c6 __NSThread__main__ + 1575
	16  libsystem_c.dylib                   0x00007fff88b448bf _pthread_start + 335
	17  libsystem_c.dylib                   0x00007fff88b47b75 thread_start + 13
)
 
terminate called throwing an exception
abort() called

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff828ed67a mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff828ecd71 mach_msg + 73
2   com.apple.CoreFoundation      	0x00007fff8d7dc6fc __CFRunLoopServiceMachPort + 188
3   com.apple.CoreFoundation      	0x00007fff8d7e4e64 __CFRunLoopRun + 1204
4   com.apple.CoreFoundation      	0x00007fff8d7e4676 CFRunLoopRunSpecific + 230
5   com.apple.HIToolbox           	0x00007fff8a49a31f RunCurrentEventLoopInMode + 277
6   com.apple.HIToolbox           	0x00007fff8a4a15c9 ReceiveNextEventCommon + 355
7   com.apple.HIToolbox           	0x00007fff8a4a1456 BlockUntilNextEventMatchingListInMode + 62
8   com.apple.AppKit              	0x00007fff89819f5d _DPSNextEvent + 659
9   com.apple.AppKit              	0x00007fff89819861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
10  com.apple.AppKit              	0x00007fff8981619d -[NSApplication run] + 470
11  com.apple.AppKit              	0x00007fff89a94b88 NSApplicationMain + 867
12  com.ftpix.ProxySwitcher       	0x0000000109f0f3b2 main + 34
13  com.ftpix.ProxySwitcher       	0x0000000109f0f384 start + 52

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib        	0x00007fff828ef7e6 kevent + 10
1   libdispatch.dylib             	0x00007fff82a655be _dispatch_mgr_invoke + 923
2   libdispatch.dylib             	0x00007fff82a6414e _dispatch_mgr_thread + 54

Thread 2 Crashed:
0   libsystem_kernel.dylib        	0x00007fff828eece2 __pthread_kill + 10
1   libsystem_c.dylib             	0x00007fff88b467d2 pthread_kill + 95
2   libsystem_c.dylib             	0x00007fff88b37a7a abort + 143
3   libc++abi.dylib               	0x00007fff8ac407bc abort_message + 214
4   libc++abi.dylib               	0x00007fff8ac3dfcf default_terminate() + 28
5   libobjc.A.dylib               	0x00007fff85dbf1b9 _objc_terminate + 94
6   libc++abi.dylib               	0x00007fff8ac3e001 safe_handler_caller(void (*)()) + 11
7   libc++abi.dylib               	0x00007fff8ac3e05c std::terminate() + 16
8   libc++abi.dylib               	0x00007fff8ac3f152 __cxa_throw + 114
9   libobjc.A.dylib               	0x00007fff85dbee7a objc_exception_throw + 327
10  com.apple.CoreFoundation      	0x00007fff8d84fdfa +[NSException raise:format:arguments:] + 106
11  com.apple.CoreFoundation      	0x00007fff8d84fd84 +[NSException raise:format:] + 116
12  com.apple.Foundation          	0x00007fff88184fce _NSFileHandleRaiseOperationException + 130
13  com.apple.Foundation          	0x00007fff8812418a -[NSConcreteFileHandle readDataOfLength:] + 99
14  com.apple.Foundation          	0x00007fff88124125 -[NSConcreteFileHandle readDataToEndOfFile] + 25
15  com.ftpix.ProxySwitcher       	0x0000000109f107b0 -[CommandLine executeCommand::] + 400
16  com.ftpix.ProxySwitcher       	0x0000000109f109b2 -[CommandLine isProxyOn::] + 290
17  com.ftpix.ProxySwitcher       	0x0000000109f10db0 -[Proxy isOn:] + 112
18  com.ftpix.ProxySwitcher       	0x0000000109f11290 -[ProxyMenu isOn] + 64
19  com.ftpix.ProxySwitcher       	0x0000000109f11205 -[ProxyMenu initWithProxy:andParent:] + 261
20  com.ftpix.ProxySwitcher       	0x0000000109f0face -[ps_AppDelegate refreshMenu] + 798
21  com.ftpix.ProxySwitcher       	0x0000000109f1053b -[ps_AppDelegate backgroundRefreshInnerThread] + 43
22  com.apple.Foundation          	0x00007fff8811074e -[NSThread main] + 68
23  com.apple.Foundation          	0x00007fff881106c6 __NSThread__main__ + 1575
24  libsystem_c.dylib             	0x00007fff88b448bf _pthread_start + 335
25  libsystem_c.dylib             	0x00007fff88b47b75 thread_start + 13

Thread 3:
0   libsystem_kernel.dylib        	0x00007fff828ef192 __workq_kernreturn + 10
1   libsystem_c.dylib             	0x00007fff88b46594 _pthread_wqthread + 758
2   libsystem_c.dylib             	0x00007fff88b47b85 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib        	0x00007fff828ef192 __workq_kernreturn + 10
1   libsystem_c.dylib             	0x00007fff88b46594 _pthread_wqthread + 758
2   libsystem_c.dylib             	0x00007fff88b47b85 start_wqthread + 13

Thread 2 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000006  rcx: 0x000000010bc98468  rdx: 0x0000000000000000
  rdi: 0x0000000000004403  rsi: 0x0000000000000006  rbp: 0x000000010bc98490  rsp: 0x000000010bc98468
   r8: 0x00007fff71addfb8   r9: 0x000000010bc97ef8  r10: 0x00007fff828eed0a  r11: 0xffffff80002d8220
  r12: 0x00007fff726a59c8  r13: 0x000000010bc9a000  r14: 0x000000010bc9a000  r15: 0x000000010bc985e0
  rip: 0x00007fff828eece2  rfl: 0x0000000000000246  cr2: 0x00007fff71addfb8
Logical CPU: 0