faboussard / 42_minishell

1 stars 0 forks source link

SEGFAULT si CTRL + D apres avoir ouvert un minishell. ce segfault nexiste pas sur ma branche new parsing, il a ete cree dans builtins a priori #111

Closed faboussard closed 5 months ago

faboussard commented 5 months ago
>>>  Minishell>$ ./minishell
==324899== Memcheck, a memory error detector
==324899== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==324899== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==324899== Command: ./minishell
==324899== 
>>>  Minishell>$ 
exit
==324899== Invalid read of size 8
==324899==    at 0x409BC0: free_safely_str (free_utils.c:42)
==324899==    by 0x40C1EC: ft_free_pl_paths (utils.c:48)
==324899==    by 0x409A85: free_minishell (free.c:87)
==324899==    by 0x401753: main (main.c:169)
==324899==  Address 0x20 is not stack'd, malloc'd or (recently) free'd
==324899== 
==324899== 
==324899== Process terminating with default action of signal 11 (SIGSEGV)
==324899==  Access not within mapped region at address 0x20
==324899==    at 0x409BC0: free_safely_str (free_utils.c:42)
==324899==    by 0x40C1EC: ft_free_pl_paths (utils.c:48)
==324899==    by 0x409A85: free_minishell (free.c:87)
==324899==    by 0x401753: main (main.c:169)
==324899==  If you believe this happened as a result of a stack
==324899==  overflow in your program's main thread (unlikely but
==324899==  possible), you can try to increase the size of the
==324899==  main thread stack using the --main-stacksize= flag.
==324899==  The main thread stack size used in this run was 8388608.
melobern commented 5 months ago

Il vient du fix des leaks de paths. Ici, il n'y avait pas de process list mais le free_minishell cherchait à free la pl. Du coup j'ai juste eu à changer ça :

if (minishell->interactive)
    ft_free_pl_paths(minishell, minishell->pl);

pour ça :

if (minishell->interactive && minishell->pl != NULL)
        ft_free_pl_paths(minishell, minishell->pl);