(Je ne sais pas si je poste dans la bonne catégorie !)
Sur un Windows 2000 Pro, j'ai un binaire qui déplace un fichier d'un répertoire A vers un répertoire B, et qui attend 3x2 minutes si jamais le fichier à déplacer n'est pas là. En résumé (C) :
Ce process bloque parfois indéfiniment ! Il peut rester pendant des heures dans l'état :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #define TO_RESOLUTION 10000 #define EXIT_TIME_OUT 223 .. static BOOL bTimeEventSet = FALSE; static UINT time_out = 6; static UINT time_sleep = 120000; static void CALLBACK time_out_proc ( UINT uNu1, UINT uNu2, DWORD dwNu3, DWORD dwNu4, DWORD dwNu5 ){ time_out--; // à time_out == 0, EXIT_TIME_OUT } main ( int argc, char *argv [ ] ){ ... uTimeEvent = timeSetEvent ( 60000, TO_RESOLUTION, ( LPTIMECALLBACK ) time_out_proc, ( DWORD ) NULL, TIME_PERIODIC ); bTimeEventSet = TRUE; // si le timeSetEvent a réussi, sinon on sort.. do { hFile = CreateFile( waitfile, GENERIC_READ, FILE_SHARE_READ, .. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, ..); error_no = GetLastError(); ... if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); ... if ( error_no != ERROR_FILE_NOT_FOUND ) { if ( error_no == ERROR_SUCCESS ) { .. exit_do = TRUE; timeKillEvent ( uTimeEvent ); ..} else fprintf ( stderr, "Error during waiting for file %s : %d. ", waitfile, error_no ); } // sinon : on poursuit l'attente tant que time_out!=0: if ( time_out != 0 ) Sleep ( time_sleep ); else { fprintf ( stderr, "Timeout. File %s not found\n", waitfile ); error_no = EXIT_TIME_OUT; if ( bTimeEventSet ) timeKillEvent ( uTimeEvent ); } } while ( error_no != EXIT_TIME_OUT && error_no != ERROR_SUCCESS && (!exit_do) ); return ( error_no ); }
Qu'est ce qui bloque ? NTDLL!ZwDelayExecution ou NTDLL!ZwWaitForMultipleObjects ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 0:000> ~0s eax=0012fef0 ebx=00410db8 ecx=00610f80 edx=00000000 esi=77f88398 edi=0012fef0 eip=77f883a3 esp=0012fedc ebp=0012fef8 iopl=0 nv up ei pl nz na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000206 NTDLL!ZwDelayExecution+0xb: 77f883a3 c20800 ret 8 0:000> kv ChildEBP RetAddr Args to Child 0012fed8 7c59a301 00000000 0012fef0 ffffffff NTDLL!ZwDelayExecution+0xb (FPO: [2,0,0]) 0012fef8 7c59a2cc 0001d4c0 00000000 0040192b KERNEL32!SleepEx+0x32 (FPO: [Non-Fpo]) 0012ff04 0040192b 0001d4c0 00000000 00000008 KERNEL32!Sleep+0xb (FPO: [1,0,0]) WARNING: Stack unwind information not available. Following frames may be wrong. 00000000 00000000 00000000 00000000 00000000 bmov+0x192b 0:000> ~1s eax=00000000 ebx=77593780 ecx=77593a78 edx=00000000 esi=77593a78 edi=00000002 eip=77f88f03 esp=00b0ff4c ebp=77f87ee0 iopl=0 nv up ei pl nz na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000202 NTDLL!ZwWaitForMultipleObjects+0xb: 77f88f03 c21400 ret 14h 0:001> kv ChildEBP RetAddr Args to Child 00b0ff48 7757932f 00000002 00b0ff74 00000001 NTDLL!ZwWaitForMultipleObjects+0xb (FPO: [5,0,0]) 00b0ffb4 7c57b3bc 00000000 00000000 00000000 winmm!timeThread+0x73 (FPO: [Uses EBP] [1,17,4]) 00b0ffec 00000000 7757927f 00000000 00000000 KERNEL32!BaseThreadStart+0x52 (FPO: [Non-Fpo])
Prototype: NtDelayExecution( IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval );
Quelqu'un peut me donner un conseil pour avancer dans ce diagnostic, parce que je ne vois trop comment identifier la raison de ce bloquage. Je suis débutant en débuggage..
Merci pour toute aide.
Merci de ne pas commenter le code (ce n'est pas le mien !). Je veux juste débugger le problème..
Partager