[so] more parser/robocheck bugreports

Bogdan Luca so@cursuri.cs.pub.ro
Wed, 10 Nov 2004 22:47:52 +0200


This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_smtp.b.astral.ro-23255-1100119659-0001-2
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


A quick and dirty patch:
2. Am facut 'robocheck_acquire_resource()' si pentru membrul 'hThread' 
al PROCESS_INFORMATION.
3. Se pare ca 'robocheck_fini()' se apeleaza inaintea lui 
'robocheck_atexit()', asa ca am mutat 'free()'-ul pe 'robocheck_exclude' 
din prima in a doua. Nu sunt sigur ca e solutia corecta, dar pana 
una-alta merge. :-)

Bogdan Luca
345CA

Bogdan Luca wrote:
> 
> Salut,
> 
> Inca una (robocheck / Windows):
> 3. Creez un proces cu 'CreateProcess(..., &piProcInfo);', dupa care fac 
> un 'CloseHandle(piProcInfo.hThread);', moment in care programul crapa cu 
> un segfault:
> ----
> Program received signal SIGSEGV, Segmentation fault.
> 0x77c42a16 in _libmsvcrt_a_iname ()
> (gdb) bt
> #0  0x77c42a16 in _libmsvcrt_a_iname ()
> #1  0x0022fd74 in ?? ()
> #2  0x77c42101 in _libmsvcrt_a_iname ()
> #3  0x63982793 in ABORT (
>     format=0x63981b10 "trying to release invalid resource 0x%x at %s:%d\n")
>     at misc.c:23
> #4  0x63981b82 in robocheck_release_resource (descriptor=4294969272, 
> line=439,
>     file=0x403b99 "exec.c") at resources.c:69
> #5  0x63981cff in robocheck_CloseHandle (line=439, file=0x403b99 "exec.c",
>     h=0x7b8) at resources.c:194
> ...
> #9  0x00404d2d in main () at main.c:33
> ----
> , deci la crearea unui proces cu 'CreateProcess(..., &piProcInfo);' ar 
> trebui tinut cont si de handle-ul 'piProcInfo.hThread'.
> (Citez din MSDN:
> ----
> Remarks
> 
> If the function [CreateProcess] succeeds, be sure to call the 
> CloseHandle function to close the hProcess and hThread handles when you 
> are finished with them. Otherwise, when the child process exits, the 
> system cannot clean up these handles because the parent process did not 
> close them. However, the system will close these handles when the parent 
> process terminates, so they would be cleaned up at this point.
> ----
> 
> Bogdan Luca
> 345CA
> 
> Bogdan Luca wrote:
> 
>>
>> Salut,
>>
>> 2 chestii:
>> 1. M-am chinuit vreo jumatate de ora sa-mi dau seama de ce nu se 
>> compileaza in Windows parser-ul cu robocheck.
>> ----
>> C:\msys\1.0\home\Bogdan Luca\so\tema1>grep -B2 -n WORD parser.tab.h
>> 30-      know about them.  */
>> 31-   enum yytokentype {
>> 32:     WORD = 258,
>> -- 
>> 47-   };
>> 48-#endif
>> 49:#define WORD 258
>> ----
>> Problema ar fi ca parser.tab.h defineste 'WORD' ca fiind '258', dupa 
>> care include 'robocheck.h', care la randul lui include 'windows.h' 
>> (unde 'WORD' ar trebui sa fie un tip definit ca in 
>> 'windef.h:234:typedef unsigned short WORD;'), rezultatul constand 
>> intr-o eroare de compilare. Solutia ar fi inlocuirea identificatorului 
>> 'WORD' cu orice alta denumire care sa nu fie folosita in alte headere 
>> (eu am folosit 'MYWORD').
>>
>> 2. Se pare ca robocheck ignora exclude-urile atunci cand face check-ul 
>> 'at process exit':
>> ----
>> C:\msys\1.0\home\Bogdan Luca\so\tema1>grep -n exclude main.c
>> 16:    robocheck_set_exclude("lex.yy.c");
>> C:\msys\1.0\home\Bogdan Luca\so\tema1>shell.exe
>> # exit
>>
>> heap leak at process exit:3748: 003F1FFC/4 allocated by lex.yy.c:1720
>> heap leak at process exit:3748: 00591FFE/16386 allocated by lex.yy.c:1720
>> heap leak at process exit:3748: 00581FD0/48 allocated by lex.yy.c:1720
>> ----
>>
>> Bogdan Luca
>> 345CA
>>
>> _______________________________________________
>> so mailing list
>> so@cursuri.cs.pub.ro
>> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
> 
> _______________________________________________
> so mailing list
> so@cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so

--=_smtp.b.astral.ro-23255-1100119659-0001-2
Content-Type: text/plain; name="robocheck.patch"; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="robocheck.patch"

diff -uNrp robocheck.orig/misc.c robocheck/misc.c
--- robocheck.orig/misc.c	2004-11-06 21:18:00.000000000 +0200
+++ robocheck/misc.c	2004-11-10 20:19:00.000000000 +0200
@@ -46,6 +46,7 @@ void robocheck_atexit(void)
 	__robocheck_resource_leaks(GLOBAL_NAMESPACE, GetCurrentProcessId(), "process exit");
 #endif
 
+	free((char*)robocheck_exclude);
 
 }
 
@@ -60,6 +61,6 @@ void robocheck_init(void)
 
 void robocheck_fini(void)
 {
-	free((char*)robocheck_exclude);
+//	free((char*)robocheck_exclude);
 }
 
diff -uNrp robocheck.orig/resources.c robocheck/resources.c
--- robocheck.orig/resources.c	2004-11-06 20:52:00.000000000 +0200
+++ robocheck/resources.c	2004-11-10 20:19:00.000000000 +0200
@@ -222,8 +222,10 @@ BOOL robocheck_CreateProcess(int line, c
 {
 	BOOL ret=CreateProcess(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10);
 	
-	if (ret)
+	if (ret) {
 		robocheck_acquire_resource(ONE_NAMESPACE|(unsigned long)_10->hProcess, line, file);
+		robocheck_acquire_resource(ONE_NAMESPACE|(unsigned long)_10->hThread, line, file);
+	}
 	return ret;
 }
 

--=_smtp.b.astral.ro-23255-1100119659-0001-2--