Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Handle parenthese in execution #31

@ZifFiji

Description

@ZifFiji
❯ valgrind ./42sh
==145947== Memcheck, a memory error detector
==145947== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==145947== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==145947== Command: ./42sh
==145947== 
➜ 42sh on  parser-lexer ❯ (ls)
==145947== Use of uninitialised value of size 8
==145947==    at 0x404550: search_and_run_builtins (compute_command.c:43)
==145947==    by 0x404868: compute_cmd (compute_command.c:128)
==145947==    by 0x4043A6: compute_pipe (compute_pipe.c:25)
==145947==    by 0x4042FA: compute_or (compute_or.c:25)
==145947==    by 0x404255: compute_and (compute_and.c:25)
==145947==    by 0x4041EA: compute_semicolon (compute_semicolon.c:24)
==145947==    by 0x404188: compute_root (compute_root.c:22)
==145947==    by 0x402650: minishell (minishell.c:69)
==145947==    by 0x408101: main (main.c:12)
==145947== 
==145947== Invalid read of size 8
==145947==    at 0x404550: search_and_run_builtins (compute_command.c:43)
==145947==    by 0x404868: compute_cmd (compute_command.c:128)
==145947==    by 0x4043A6: compute_pipe (compute_pipe.c:25)
==145947==    by 0x4042FA: compute_or (compute_or.c:25)
==145947==    by 0x404255: compute_and (compute_and.c:25)
==145947==    by 0x4041EA: compute_semicolon (compute_semicolon.c:24)
==145947==    by 0x404188: compute_root (compute_root.c:22)
==145947==    by 0x402650: minishell (minishell.c:69)
==145947==    by 0x408101: main (main.c:12)
==145947==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==145947== 
==145947== 
==145947== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==145947==  Access not within mapped region at address 0x0
==145947==    at 0x404550: search_and_run_builtins (compute_command.c:43)
==145947==    by 0x404868: compute_cmd (compute_command.c:128)
==145947==    by 0x4043A6: compute_pipe (compute_pipe.c:25)
==145947==    by 0x4042FA: compute_or (compute_or.c:25)
==145947==    by 0x404255: compute_and (compute_and.c:25)
==145947==    by 0x4041EA: compute_semicolon (compute_semicolon.c:24)
==145947==    by 0x404188: compute_root (compute_root.c:22)
==145947==    by 0x402650: minishell (minishell.c:69)
==145947==    by 0x408101: main (main.c:12)
==145947==  If you believe this happened as a result of a stack
==145947==  overflow in your program's main thread (unlikely but
==145947==  possible), you can try to increase the size of the
==145947==  main thread stack using the --main-stacksize= flag.
==145947==  The main thread stack size used in this run was 8388608.
==145947== 
==145947== HEAP SUMMARY:
==145947==     in use at exit: 6,144 bytes in 219 blocks
==145947==   total heap usage: 295 allocs, 76 frees, 25,518 bytes allocated
==145947== 
==145947== LEAK SUMMARY:
==145947==    definitely lost: 467 bytes in 22 blocks
==145947==    indirectly lost: 48 bytes in 2 blocks
==145947==      possibly lost: 0 bytes in 0 blocks
==145947==    still reachable: 5,629 bytes in 195 blocks
==145947==         suppressed: 0 bytes in 0 blocks
==145947== Rerun with --leak-check=full to see details of leaked memory
==145947== 
==145947== Use --track-origins=yes to see where uninitialised values come from
==145947== For lists of detected and suppressed errors, rerun with: -s
==145947== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
[1]    145947 segmentation fault (core dumped)  valgrind ./42sh

Il faut juste prendre en compte que la structure command peut ne pas avoir de exec_name mais seulement un sub_shell qui lui contient des commandes etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions