[so] robocheck issues + rugaminte

Bogdan Luca so@cursuri.cs.pub.ro
Mon, 08 Nov 2004 01:41:21 +0200


Si inca una (parser+robocheck):
4. in cazul introducerii unei comenzi eronate (de exemplu 'a|'), apar 
doua probleme: yyparse nu se intoarce decat dupa ce mai introducem un 
ENTER, si, deoarece command va fi NULL, nu vom putea dealoca resursele 
alocate la parsare (am reprezentat prin <CR> apasarea tastei ENTER):
----
luck@devel tema1 $ ./shell<CR>
(6175:/home/luck/so/tema1)# a|<CR>
error: syntax error
<CR>
back from yyparse()
(6175:/home/luck/so/tema1)# exit<CR>
back from yyparse()
heap leak at main.c:127: 0xb7fe0fdc/36 allocated by parser.y:74
heap leak at main.c:127: 0xb7fe6ff0/16 allocated by parser.y:28
heap leak at main.c:127: 0xb7fe3fe8/24 allocated by parser.y:41
heap leak at main.c:127: 0xb7fe9ffe/2 allocated by parser.l:25

heap leak at process exit:6175: 0xb7fe0fdc/36 allocated by parser.y:74
heap leak at process exit:6175: 0xb7fe6ff0/16 allocated by parser.y:28
heap leak at process exit:6175: 0xb7fe3fe8/24 allocated by parser.y:41
heap leak at process exit:6175: 0xb7fe9ffe/2 allocated by parser.l:25
luck@devel tema1 $
----
Idei?

Bogdan Luca
345CA

Bogdan Luca wrote:
> 
> Scuze, am uitat o problema:
> 3. pentru a inchide automat toate fisierele/pipe-urile deschise dar 
> nenecesare in child in momentul in care apelez 'execvp()', am setat 
> flag-ul close-on-exec dupa 'open()'/'pipe()' pentru toate aceste 
> fisiere/pipe-uri, problema e ca robocheck-ul nu isi da seama de lucrul 
> asta:
> ----
> resource leak at exec.c:308: 0x3, acquired at exec.c:231
> ----
> (in cazul rularii unei comenzi cu redirectare intr-un fisier; linia 308 
> contine 'execvp()'-ul, iar linia 231 contine 'open()'-ul). Inca n-am 
> gasit un workaround (prefer sa nu ma chinui sa inchid fisierele 
> 'manual', e o exemplificare buna a utilitatii/utilizarii flag-ului 
> close-on-exec); se penalizeaza warning-ul respectiv?
> 
> Si inca o intrebare (n-am gasit pe nicaieri specificat explicit): 
> flag-ul close-on-exec se mosteneste la 'fork()'?
> 
> Bogdan Luca
> 345CA
> 
> Bogdan Luca wrote:
> 
>>
>> Salut,
>>
>> Am sesizat doua mici probleme cu robocheck-ul, si ma intrebam daca 
>> exista si alte workaround-uri pentru ele:
>> 1. nu recunoaste 'calloc()' (desi face parte din standardul ANSI-C); 
>> workaround-ul a fost sa folosesc 'malloc()'+'memset()';
>> 2. in momentul in care lansez o comanda cu stdin-ul redirectat (de 
>> exemplu; acelasi lucru se intampla si pentru std[out|err]) deschid 
>> fisierul din care se face redirectarea ('fd = open();'), fac un 
>> 'fork()' si din child (incerc sa) fac 'close(0); dup2(fd, 0);'; 
>> problema e ca in momentul in care incerc sa fac 'close()'-ul 
>> robocheck-ul da un segfault:
>> ----
>> ...
>> Core was generated by `./shell'.
>> Program terminated with signal 11, Segmentation fault.
>> ...
>> (gdb) bt
>> ...
>> #5  0xb7ff79e2 in robocheck_release_resource () from 
>> /usr/lib/librobocheck.so
>> #6  0xb7ff7b78 in robocheck_close () from /usr/lib/librobocheck.so
>> #7  0x0804ac91 in exec_command_exec_cmd (exec_command=0xb7fd7fd8, 
>> cmd=0xb7fd4fd8) at exec.c:293
>> ...
>> #10 0x0804b367 in main () at main.c:121
>> ----
>> (probabil din cauza ca il 'deranjeaza' faptul ca incerc sa inchid 
>> fd-ul 0 fara sa-l fi deschis in prealabil); workaround-ul a fost sa 
>> renunt la 'close()', fd-ul 0 fiind inchis oricum de 'dup2()' (desi in 
>> pagina de manual a lui 'dup2()' zice, citez:
>> ----
>>        If newfd was open, any errors that would have been reported at 
>> close() time,  are lost. A careful programmer will not use dup2 
>> without closing newfd first.
>> ----
>> ).
>>
>> Ar mai fi o rugaminte (si probabil ca aici sunt in asentimentul 
>> colegilor mei): avand in vedere ca au fost cateva probleme cu tema 1 
>> (modificarea parser-ului, integrarea robocheck-ului), s-ar putea amana 
>> deadline-ul, daca nu cu 24 de ore, macar cu 12?
>>
>> Multumesc anticipat,
>> 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