faboussard / 42_minishell

1 stars 0 forks source link

Si infile, reste ouvert depuis derniers changements #52

Closed melobern closed 5 months ago

melobern commented 5 months ago
➜  42_minishell.c git:(builtins) ✗ valgrind --track-fds=yes ./minishell -c "< oui | ls | wc -l"
==30136== Memcheck, a memory error detector
==30136== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==30136== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==30136== Command: ./minishell -c \<\ oui\ |\ ls\ |\ wc\ -l
==30136== 
==30137== Invalid read of size 1
==30137==    at 0x110412: ft_strncmp (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10F405: exec_several_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10E6FE: execute_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10A62B: main (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==30137== 
==30137== 
==30137== Process terminating with default action of signal 11 (SIGSEGV)
==30137==  Access not within mapped region at address 0x0
==30137==    at 0x110412: ft_strncmp (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10F405: exec_several_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10E6FE: execute_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10A62B: main (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==  If you believe this happened as a result of a stack
==30137==  overflow in your program's main thread (unlikely but
==30137==  possible), you can try to increase the size of the
==30137==  main thread stack using the --main-stacksize= flag.
==30137==  The main thread stack size used in this run was 8388608.
==30137== 
==30137== FILE DESCRIPTORS: 5 open (3 std) at exit.
==30137== Open file descriptor 4: /dev/pts/0
==30137==    at 0x49D3FEB: dup (syscall-template.S:120)
==30137==    by 0x10EF6E: dup_original_fds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10E680: execute_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10A62B: main (in /home/melodie/Documents/42_minishell.c/minishell)
==30137== 
==30137== Open file descriptor 3: /dev/pts/0
==30137==    at 0x49D3FEB: dup (syscall-template.S:120)
==30137==    by 0x10EF40: dup_original_fds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10E680: execute_cmds (in /home/melodie/Documents/42_minishell.c/minishell)
==30137==    by 0x10A62B: main (in /home/melodie/Documents/42_minishell.c/minishell)
melobern commented 5 months ago

Normal, c'est l’entrée et la sortie standard (dup_originals_fds), ils sont bien fermés à la toute fin du minishell.

Reste à voir le segfault.

melobern commented 5 months ago

Segfault résolu. Quand la commande est < file | cmd, dans child_care.c, ça vérifie si cmd_table[0] existe avant de lancer la fonction ft_strncmp.