Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash echo + pipe #24

Closed
Gwojda opened this issue Feb 18, 2017 · 2 comments
Closed

crash echo + pipe #24

Gwojda opened this issue Feb 18, 2017 · 2 comments
Assignees

Comments

@Gwojda
Copy link
Collaborator

Gwojda commented Feb 18, 2017

➜ 42sh_test_completion git:(master) ✗ echo "test" | grep "test"
==74809== Invalid read of size 8
==74809== at 0x100010FF4: job_addprocess (job_addprocess.c:29)
==74809== by 0x10000A94D: exec_command (exec_command.c:59)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x10000AD2E: exec_pipe (exec_pipe.c:40)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x100019713: interactive_shell (main.c:75)
==74809== by 0x100019802: main (main.c:92)
==74809== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==74809==
==74809==
==74809== Process terminating with default action of signal 11 (SIGSEGV)
==74809== Access not within mapped region at address 0x0
==74809== at 0x100010FF4: job_addprocess (job_addprocess.c:29)
==74809== by 0x10000A94D: exec_command (exec_command.c:59)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x10000AD2E: exec_pipe (exec_pipe.c:40)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x100019713: interactive_shell (main.c:75)
==74809== by 0x100019802: main (main.c:92)
==74809== If you believe this happened as a result of a stack
==74809== overflow in your program's main thread (unlikely but
==74809== possible), you can try to increase the size of the
==74809== main thread stack using the --main-stacksize= flag.
==74809== The main thread stack size used in this run was 8388608.
==74809==
==74809== HEAP SUMMARY:
==74809== in use at exit: 139,383 bytes in 821 blocks
==74809== total heap usage: 1,943 allocs, 1,122 frees, 212,695 bytes allocated
==74809==
==74809== 34 (24 direct, 10 indirect) bytes in 1 blocks are definitely lost in loss record 57 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100004494: ft_memalloc (ft_memalloc.c:20)
==74809== by 0x100004A88: ft_sstradd (ft_sstradd.c:26)
==74809== by 0x10000AA77: token_to_argv (exec_command.c:34)
==74809== by 0x10000A918: exec_command (exec_command.c:55)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x10000ACCD: exec_pipe (exec_pipe.c:31)
==74809== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74809== by 0x100019713: interactive_shell (main.c:75)
==74809== by 0x100019802: main (main.c:92)
==74809==
==74809== 40 bytes in 1 blocks are definitely lost in loss record 58 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100014883: token_init (token_init.c:19)
==74809== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74809== by 0x1000195CD: interactive_shell (main.c:62)
==74809== by 0x100019802: main (main.c:92)
==74809==
==74809== 40 bytes in 1 blocks are definitely lost in loss record 59 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100014883: token_init (token_init.c:19)
==74809== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74809== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014224: lexer_word (lexer_word.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x1000132BE: lexer_dquote (lexer_dquote.c:31)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x1000133C4: lexer_dquote (lexer_dquote.c:50)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x1000133C4: lexer_dquote (lexer_dquote.c:50)
==74809==
==74809== 40 bytes in 1 blocks are definitely lost in loss record 60 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100014883: token_init (token_init.c:19)
==74809== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74809== by 0x1000141BF: lexer_sep (lexer_sep.c:42)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100012DFA: lexer_default (lexer_default.c:22)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014224: lexer_word (lexer_word.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x1000132BE: lexer_dquote (lexer_dquote.c:31)
==74809==
==74809== 41 bytes in 1 blocks are definitely lost in loss record 63 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100004494: ft_memalloc (ft_memalloc.c:20)
==74809== by 0x1000010D4: btree_create_node (btree_create_node.c:31)
==74809== by 0x100019E51: ft_parse (ft_parse.c:38)
==74809== by 0x10001A856: parse_separator (parse_separator.c:25)
==74809== by 0x100019EE8: ft_parse (ft_parse.c:44)
==74809== by 0x1000196E0: interactive_shell (main.c:72)
==74809== by 0x100019802: main (main.c:92)
==74809==
==74809== 58 (48 direct, 10 indirect) bytes in 2 blocks are definitely lost in loss record 72 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100003B2E: ft_lstnew (ft_lstnew.c:19)
==74809== by 0x100003D3C: push (push.c:17)
==74809== by 0x100013279: lexer_dquote (lexer_dquote.c:26)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100012DFA: lexer_default (lexer_default.c:22)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014224: lexer_word (lexer_word.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014290: lexer_word (lexer_word.c:34)
==74809==
==74809== 80 bytes in 2 blocks are definitely lost in loss record 84 of 129
==74809== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74809== by 0x100014883: token_init (token_init.c:19)
==74809== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74809== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014224: lexer_word (lexer_word.c:25)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014290: lexer_word (lexer_word.c:34)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014290: lexer_word (lexer_word.c:34)
==74809== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74809== by 0x100014290: lexer_word (lexer_word.c:34)
==74809==
==74809== LEAK SUMMARY:
==74809== definitely lost: 313 bytes in 9 blocks
==74809== indirectly lost: 20 bytes in 4 blocks
==74809== possibly lost: 0 bytes in 0 blocks
==74809== still reachable: 112,724 bytes in 617 blocks
==74809== suppressed: 26,326 bytes in 191 blocks
==74809== Reachable blocks (those to which a pointer was found) are not shown.
==74809== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==74809==
==74809== For counts of detected and suppressed errors, rerun with: -v
==74809== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 14 from 14)
[1] 74809 segmentation fault valgrind --leak-check=full ./42sh 3> test

@Gwojda
Copy link
Collaborator Author

Gwojda commented Feb 18, 2017

dans le meme genre :

Crash sur cd | pwd

➜ 42sh_test_completion git:(master) ✗ cd | pwd
==74964== Invalid read of size 8
==74964== at 0x100010FF4: job_addprocess (job_addprocess.c:29)
==74964== by 0x10000A94D: exec_command (exec_command.c:59)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x10000AD2E: exec_pipe (exec_pipe.c:40)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x100019713: interactive_shell (main.c:75)
==74964== by 0x100019802: main (main.c:92)
==74964== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==74964==
==74964==
==74964== Process terminating with default action of signal 11 (SIGSEGV)
==74964== Access not within mapped region at address 0x0
==74964== at 0x100010FF4: job_addprocess (job_addprocess.c:29)
==74964== by 0x10000A94D: exec_command (exec_command.c:59)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x10000AD2E: exec_pipe (exec_pipe.c:40)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x100019713: interactive_shell (main.c:75)
==74964== by 0x100019802: main (main.c:92)
==74964== If you believe this happened as a result of a stack
==74964== overflow in your program's main thread (unlikely but
==74964== possible), you can try to increase the size of the
==74964== main thread stack using the --main-stacksize= flag.
==74964== The main thread stack size used in this run was 8388608.
==74964==
==74964== HEAP SUMMARY:
==74964== in use at exit: 139,146 bytes in 810 blocks
==74964== total heap usage: 1,774 allocs, 964 frees, 206,170 bytes allocated
==74964==
/Users/gwojda
==74964== 19 (16 direct, 3 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 123
==74964== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74964== by 0x100004494: ft_memalloc (ft_memalloc.c:20)
==74964== by 0x100004A88: ft_sstradd (ft_sstradd.c:26)
==74964== by 0x10000AA77: token_to_argv (exec_command.c:34)
==74964== by 0x10000A918: exec_command (exec_command.c:55)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x10000ACCD: exec_pipe (exec_pipe.c:31)
==74964== by 0x10000AF78: ft_exec (ft_exec.c:39)
==74964== by 0x100019713: interactive_shell (main.c:75)
==74964== by 0x100019802: main (main.c:92)
==74964==
==74964== 40 bytes in 1 blocks are definitely lost in loss record 53 of 123
==74964== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74964== by 0x100014883: token_init (token_init.c:19)
==74964== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74964== by 0x1000195CD: interactive_shell (main.c:62)
==74964== by 0x100019802: main (main.c:92)
==74964==
==74964== 40 bytes in 1 blocks are definitely lost in loss record 54 of 123
==74964== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74964== by 0x100014883: token_init (token_init.c:19)
==74964== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74964== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100014224: lexer_word (lexer_word.c:25)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100014290: lexer_word (lexer_word.c:34)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100014290: lexer_word (lexer_word.c:34)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100012E76: lexer_default (lexer_default.c:28)
==74964==
==74964== 40 bytes in 1 blocks are definitely lost in loss record 55 of 123
==74964== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74964== by 0x100014883: token_init (token_init.c:19)
==74964== by 0x100013B85: lexer_lex (lexer_lex.c:51)
==74964== by 0x1000141BF: lexer_sep (lexer_sep.c:42)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100012DFA: lexer_default (lexer_default.c:22)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100012F10: lexer_delim (lexer_delim.c:25)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100014224: lexer_word (lexer_word.c:25)
==74964== by 0x100013BC1: lexer_lex (lexer_lex.c:54)
==74964== by 0x100014290: lexer_word (lexer_word.c:34)
==74964==
==74964== 41 bytes in 1 blocks are definitely lost in loss record 58 of 123
==74964== at 0x10003F671: malloc (in /Users/gwojda/.brew/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==74964== by 0x100004494: ft_memalloc (ft_memalloc.c:20)
==74964== by 0x1000010D4: btree_create_node (btree_create_node.c:31)
==74964== by 0x100019E51: ft_parse (ft_parse.c:38)
==74964== by 0x10001A856: parse_separator (parse_separator.c:25)
==74964== by 0x100019EE8: ft_parse (ft_parse.c:44)
==74964== by 0x1000196E0: interactive_shell (main.c:72)
==74964== by 0x100019802: main (main.c:92)
==74964==
==74964== LEAK SUMMARY:
==74964== definitely lost: 177 bytes in 5 blocks
==74964== indirectly lost: 3 bytes in 1 blocks
==74964== possibly lost: 0 bytes in 0 blocks
==74964== still reachable: 112,640 bytes in 613 blocks
==74964== suppressed: 26,326 bytes in 191 blocks
==74964== Reachable blocks (those to which a pointer was found) are not shown.
==74964== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==74964==
==74964== For counts of detected and suppressed errors, rerun with: -v
==74964== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 14 from 14)
[1] 74964 segmentation fault valgrind --leak-check=full ./42sh 3> test

@Gwojda
Copy link
Collaborator Author

Gwojda commented Feb 18, 2017

➜ 42sh_test_completion git:(master) ✗ valgrind --leak-check=full ./42sh 3>test
==75121== Memcheck, a memory error detector
==75121== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==75121== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==75121== Command: ./42sh
==75121==
--75121-- UNKNOWN fcntl 67!
--75121-- UNKNOWN fcntl 67! (repeated 2 times)
➜ 42sh_test_completion git:(master) ✗ echo | echo

➜ 42sh_test_completion git:(master) ✗ echo | echo

➜ 42sh_test_completion ==75121==
==75121== Process terminating with default action of signal 13 (SIGPIPE)
==75121== at 0x100005913: ft_strnew (ft_strnew.c:25)
==75121== by 0x100005588: ft_strjoin (ft_strjoin.c:19)
==75121== by 0x1000036B0: ft_loop_read (get_next_line.c:46)
==75121== by 0x10000357C: get_next_line (get_next_line.c:78)
==75121== by 0x1000153DB: ft_git_status (ft_prompt.c:31)
==75121== by 0x100015166: ft_prompt (ft_prompt.c:104)
==75121== by 0x100018B5F: readline_init (readline.c:95)
==75121== by 0x100018B84: readline (readline.c:102)
==75121== by 0x1000194EF: interactive_shell (main.c:56)
==75121== by 0x100019802: main (main.c:92)
==75121==
==75121== HEAP SUMMARY:
==75121== in use at exit: 139,487 bytes in 820 blocks
==75121== total heap usage: 2,100 allocs, 1,280 frees, 210,727 bytes allocated

@jzck jzck closed this as completed Mar 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants