jzck / 42sh

:four::two: bash-like shell (school project)
7 stars 2 forks source link

leaks subshell + redir/pipe #198

Closed Gwojda closed 7 years ago

Gwojda commented 7 years ago
➜  42sh git:(master) ✗ (ls) | vim

==12825== 29 (24 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 41 of 75
==12825==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12825==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==12825==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==12825==    by 0x41BE40: push (in /home/gwojda/42sh/42sh)
==12825==    by 0x4073A0: exec_semi (in /home/gwojda/42sh/42sh)
==12825==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==12825==    by 0x416DB4: ??? (in /home/gwojda/42sh/42sh)
==12825==    by 0x416E59: main (in /home/gwojda/42sh/42sh)
Gwojda commented 7 years ago
➜  42sh git:(master) ✗ (ls) | sleep 5 &
[1] 12755 12756
➜  42sh git:(master) ✗ ==12755== 
==12755== HEAP SUMMARY:
==12755==     in use at exit: 22,192 bytes in 627 blocks
==12755==   total heap usage: 1,263 allocs, 636 frees, 211,052 bytes allocated
==12755== 
==12755== 58 (24 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 57 of 76
==12755==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12755==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==12755==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==12755==    by 0x41BE40: push (in /home/gwojda/42sh/42sh)
==12755==    by 0x406A66: exec_ampersand (in /home/gwojda/42sh/42sh)
==12755==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==12755==    by 0x4073B3: exec_semi (in /home/gwojda/42sh/42sh)
==12755==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==12755==    by 0x416DB4: ??? (in /home/gwojda/42sh/42sh)
==12755==    by 0x416E59: main (in /home/gwojda/42sh/42sh)
Gwojda commented 7 years ago
➜  42sh git:(master) ✗ (ls) > test
==12829== Conditional jump or move depends on uninitialised value(s)
==12829==    at 0x41D72F: open_access (in /home/gwojda/42sh/42sh)
==12829==    by 0x408DC3: redirect_great (in /home/gwojda/42sh/42sh)
==12829==    by 0x408414: process_redirect (in /home/gwojda/42sh/42sh)
==12829==    by 0x4081C0: process_fork (in /home/gwojda/42sh/42sh)
==12829==    by 0x408280: process_launch (in /home/gwojda/42sh/42sh)
==12829==    by 0x40706B: exec_leaf (in /home/gwojda/42sh/42sh)
==12829==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==12829==    by 0x4073B3: exec_semi (in /home/gwojda/42sh/42sh)
==12829==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==12829==    by 0x416DB4: ??? (in /home/gwojda/42sh/42sh)
==12829==    by 0x416E59: main (in /home/gwojda/42sh/42sh)
==12829== 
Gwojda commented 7 years ago

Certainement les memes que plus hauts, mais sait-on jamais :

➜  42sh git:(master) ✗ (ls) | (ls) | (ls)
21sh_error  42sh  42ShellTester  42sh_error  auteur  donovan_segaults_06-02  includes  libft  Makefile  minishell_error  objs  outv  pdf  README.md  sample  scriptheader.sh  src  test  update_makefile.sh
==13193== 
==13193== HEAP SUMMARY:
==13193==     in use at exit: 30,908 bytes in 664 blocks
==13193==   total heap usage: 1,384 allocs, 720 frees, 221,091 bytes allocated
==13193== 
==13193== 58 (24 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 56 of 80
==13193==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==13193==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==13193==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==13193==    by 0x41BE40: push (in /home/gwojda/42sh/42sh)
==13193==    by 0x40718C: exec_pipe (in /home/gwojda/42sh/42sh)
==13193==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13193==    by 0x4073B3: exec_semi (in /home/gwojda/42sh/42sh)
==13193==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13193==    by 0x416DB4: ??? (in /home/gwojda/42sh/42sh)
==13193==    by 0x416E59: main (in /home/gwojda/42sh/42sh)
==13193== 
==13193== LEAK SUMMARY:
==13193==    definitely lost: 24 bytes in 1 blocks
==13193==    indirectly lost: 34 bytes in 3 blocks
==13193==      possibly lost: 0 bytes in 0 blocks
==13193==    still reachable: 30,850 bytes in 660 blocks
==13193==         suppressed: 0 bytes in 0 blocks
==13193== Reachable blocks (those to which a pointer was found) are not shown.
==13193== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==13193== 
==13193== For counts of detected and suppressed errors, rerun with: -v
==13193== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==13194== 
==13194== HEAP SUMMARY:
==13194==     in use at exit: 31,264 bytes in 673 blocks
==13194==   total heap usage: 1,395 allocs, 722 frees, 221,476 bytes allocated
==13194== 
==13195== 
==13195== HEAP SUMMARY:
==13195==     in use at exit: 31,507 bytes in 680 blocks
==13195==   total heap usage: 1,404 allocs, 724 frees, 221,748 bytes allocated
==13195== 
==13195== 657 (24 direct, 633 indirect) bytes in 1 blocks are definitely lost in loss record 84 of 91
==13195==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==13195==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==13195==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==13195==    by 0x40EF55: job_addprocess (in /home/gwojda/42sh/42sh)
==13195==    by 0x40707B: exec_leaf (in /home/gwojda/42sh/42sh)
==13195==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13195==    by 0x40719F: exec_pipe (in /home/gwojda/42sh/42sh)
==13195==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13195==    by 0x40719F: exec_pipe (in /home/gwojda/42sh/42sh)
==13195==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13195==    by 0x4073B3: exec_semi (in /home/gwojda/42sh/42sh)
==13195==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13195== 
==13194== 29 (24 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 46 of 89
==13195== LEAK SUMMARY:
==13195==    definitely lost: 24 bytes in 1 blocks
==13195==    indirectly lost: 633 bytes in 19 blocks
==13195==      possibly lost: 0 bytes in 0 blocks
==13195==    still reachable: 30,850 bytes in 660 blocks
==13195==         suppressed: 0 bytes in 0 blocks
==13195== Reachable blocks (those to which a pointer was found) are not shown.
==13195== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==13195== 
==13195== For counts of detected and suppressed errors, rerun with: -v
==13195== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==13194==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==13194==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==13194==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==13194==    by 0x41BE40: push (in /home/gwojda/42sh/42sh)
==13194==    by 0x4073A0: exec_semi (in /home/gwojda/42sh/42sh)
==13194==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13194==    by 0x416DB4: ??? (in /home/gwojda/42sh/42sh)
==13194==    by 0x416E59: main (in /home/gwojda/42sh/42sh)
==13194== 
==13194== 385 (24 direct, 361 indirect) bytes in 1 blocks are definitely lost in loss record 79 of 89
==13194==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==13194==    by 0x41C037: ft_malloc (in /home/gwojda/42sh/42sh)
==13194==    by 0x41BC61: ft_lstnew (in /home/gwojda/42sh/42sh)
==13194==    by 0x40EF55: job_addprocess (in /home/gwojda/42sh/42sh)
==13194==    by 0x40707B: exec_leaf (in /home/gwojda/42sh/42sh)
==13194==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13194==    by 0x40719F: exec_pipe (in /home/gwojda/42sh/42sh)
==13194==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13194==    by 0x40719F: exec_pipe (in /home/gwojda/42sh/42sh)
==13194==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13194==    by 0x4073B3: exec_semi (in /home/gwojda/42sh/42sh)
==13194==    by 0x4075C9: ft_exec (in /home/gwojda/42sh/42sh)
==13194== 
==13194== LEAK SUMMARY:
==13194==    definitely lost: 48 bytes in 2 blocks
==13194==    indirectly lost: 366 bytes in 11 blocks
==13194==      possibly lost: 0 bytes in 0 blocks
==13194==    still reachable: 30,850 bytes in 660 blocks
==13194==         suppressed: 0 bytes in 0 blocks
==13194== Reachable blocks (those to which a pointer was found) are not shown.
==13194== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==13194== 
==13194== For counts of detected and suppressed errors, rerun with: -v
==13194== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
wescande commented 7 years ago

@Gwojda Yo, que des leaks des fils, mais si on arrive a les résoudre c'est mieux :)

jzck commented 7 years ago

je n'ai pas valgrind à la maison mais j'ai bon espoir que ce dernier commit ait occis ces leaks

Gwojda commented 7 years ago

ceux toujours present :

➜  42sh git:(rendu_minishell) ✗ (ls) | grep "toto"
==12789== 
==12789== HEAP SUMMARY:
==12789==     in use at exit: 32,867 bytes in 794 blocks
==12789==   total heap usage: 5,256 allocs, 4,462 frees, 2,342,649 bytes allocated
==12789== 
==12789== 29 (24 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 43 of 79
==12789==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12789==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12789==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12789==    by 0x41BDA4: push (in /home/gwojda/42sh/42sh)
==12789==    by 0x418CC2: exec_semi (in /home/gwojda/42sh/42sh)
==12789==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12789==    by 0x40AEA4: ??? (in /home/gwojda/42sh/42sh)
==12789==    by 0x40AF49: main (in /home/gwojda/42sh/42sh)
Gwojda commented 7 years ago
➜  42sh git:(rendu_minishell) ✗ (ls) | (ls) | (ls)
42sh  auteur  includes  libft  Makefile  minishell  objs  outv  pdf  README.md  src  test  update_makefile.sh
==12845== 
==12845== HEAP SUMMARY:
==12845==     in use at exit: 33,382 bytes in 816 blocks
==12845==   total heap usage: 5,987 allocs, 5,171 frees, 2,715,832 bytes allocated
==12845== 
==12845== 58 (24 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 59 of 85
==12845==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12845==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12845==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12845==    by 0x41BDA4: push (in /home/gwojda/42sh/42sh)
==12845==    by 0x41827A: exec_pipe (in /home/gwojda/42sh/42sh)
==12845==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12845==    by 0x418CD5: exec_semi (in /home/gwojda/42sh/42sh)
==12845==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12845==    by 0x40AEA4: ??? (in /home/gwojda/42sh/42sh)
==12845==    by 0x40AF49: main (in /home/gwojda/42sh/42sh)
==12845== 
==12845== LEAK SUMMARY:
==12845==    definitely lost: 24 bytes in 1 blocks
==12845==    indirectly lost: 34 bytes in 3 blocks
==12845==      possibly lost: 0 bytes in 0 blocks
==12845==    still reachable: 33,324 bytes in 812 blocks
==12845==         suppressed: 0 bytes in 0 blocks
==12845== Reachable blocks (those to which a pointer was found) are not shown.
==12845== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==12845== 
==12845== For counts of detected and suppressed errors, rerun with: -v
==12845== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==12847== 
==12846== 
==12847== HEAP SUMMARY:
==12847==     in use at exit: 33,981 bytes in 832 blocks
==12847==   total heap usage: 6,007 allocs, 5,175 frees, 2,716,489 bytes allocated
==12847== 
==12846== HEAP SUMMARY:
==12846==     in use at exit: 33,738 bytes in 825 blocks
==12846==   total heap usage: 5,998 allocs, 5,173 frees, 2,716,217 bytes allocated
==12846== 
==12846== 29 (24 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 46 of 94
==12847== 657 (24 direct, 633 indirect) bytes in 1 blocks are definitely lost in loss record 89 of 96
==12846==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12846==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12846==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12847==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12846==    by 0x41BDA4: push (in /home/gwojda/42sh/42sh)
==12847==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12846==    by 0x418CC2: exec_semi (in /home/gwojda/42sh/42sh)
==12846==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846==    by 0x40AEA4: ??? (in /home/gwojda/42sh/42sh)
==12846==    by 0x40AF49: main (in /home/gwojda/42sh/42sh)
==12846== 
==12847==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12847==    by 0x406AF2: job_addprocess (in /home/gwojda/42sh/42sh)
==12847==    by 0x418E9A: exec_leaf (in /home/gwojda/42sh/42sh)
==12846== 385 (24 direct, 361 indirect) bytes in 1 blocks are definitely lost in loss record 84 of 94
==12846==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12846==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12847==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12846==    by 0x406AF2: job_addprocess (in /home/gwojda/42sh/42sh)
==12846==    by 0x418E9A: exec_leaf (in /home/gwojda/42sh/42sh)
==12846==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846==    by 0x41828D: exec_pipe (in /home/gwojda/42sh/42sh)
==12846==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846==    by 0x41828D: exec_pipe (in /home/gwojda/42sh/42sh)
==12846==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846==    by 0x418CD5: exec_semi (in /home/gwojda/42sh/42sh)
==12846==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846== 
==12847==    by 0x41828D: exec_pipe (in /home/gwojda/42sh/42sh)
==12847==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12846== LEAK SUMMARY:
==12846==    definitely lost: 48 bytes in 2 blocks
==12846==    indirectly lost: 366 bytes in 11 blocks
==12846==      possibly lost: 0 bytes in 0 blocks
==12846==    still reachable: 33,324 bytes in 812 blocks
==12846==         suppressed: 0 bytes in 0 blocks
==12846== Reachable blocks (those to which a pointer was found) are not shown.
==12846== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==12846== 
==12847==    by 0x41828D: exec_pipe (in /home/gwojda/42sh/42sh)
==12846== For counts of detected and suppressed errors, rerun with: -v
==12846== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==12847==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12847==    by 0x418CD5: exec_semi (in /home/gwojda/42sh/42sh)
==12847==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12847== 
==12847== LEAK SUMMARY:
==12847==    definitely lost: 24 bytes in 1 blocks
==12847==    indirectly lost: 633 bytes in 19 blocks
==12847==      possibly lost: 0 bytes in 0 blocks
==12847==    still reachable: 33,324 bytes in 812 blocks
==12847==         suppressed: 0 bytes in 0 blocks
==12847== Reachable blocks (those to which a pointer was found) are not shown.
==12847== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==12847== 
==12847== For counts of detected and suppressed errors, rerun with: -v
==12847== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Gwojda commented 7 years ago
➜  42sh git:(rendu_minishell) ✗ (ls) | sleep 5 &
[1] 12861 12862
➜  42sh git:(rendu_minishell) ✗ ==12861== 
==12861== HEAP SUMMARY:
==12861==     in use at exit: 33,238 bytes in 814 blocks
==12861==   total heap usage: 6,500 allocs, 5,686 frees, 2,725,202 bytes allocated
==12861== 
==12861== 58 (24 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 62 of 84
==12861==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==12861==    by 0x41BF9B: ft_malloc (in /home/gwojda/42sh/42sh)
==12861==    by 0x41BBC5: ft_lstnew (in /home/gwojda/42sh/42sh)
==12861==    by 0x41BDA4: push (in /home/gwojda/42sh/42sh)
==12861==    by 0x417CBC: exec_ampersand (in /home/gwojda/42sh/42sh)
==12861==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12861==    by 0x418CD5: exec_semi (in /home/gwojda/42sh/42sh)
==12861==    by 0x4191FA: ft_exec (in /home/gwojda/42sh/42sh)
==12861==    by 0x40AEA4: ??? (in /home/gwojda/42sh/42sh)
==12861==    by 0x40AF49: main (in /home/gwojda/42sh/42sh)
==12861== 
==12861== LEAK SUMMARY:
==12861==    definitely lost: 24 bytes in 1 blocks
==12861==    indirectly lost: 34 bytes in 3 blocks
==12861==      possibly lost: 0 bytes in 0 blocks
==12861==    still reachable: 33,180 bytes in 810 blocks
==12861==         suppressed: 0 bytes in 0 blocks
==12861== Reachable blocks (those to which a pointer was found) are not shown.
==12861== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==12861== 
==12861== For counts of detected and suppressed errors, rerun with: -v
==12861== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Gwojda commented 7 years ago

(ls) > test Ne leaks plus !

dariuskramer commented 7 years ago

tu peux réessayer stp ? je pense que javais pas fix sur master...

Gwojda commented 7 years ago

C\est tout bon ! Je close ! GG