JonasGoetz01 / 42-minishell

Built your very own shell, Minishell! Explore executing commands, managing history, and controlling inputs and outputs. Dive into handling processes and files while creating a user-friendly shell interface. Get hands-on with shell scripting in a fun and accessible way with Minishell (DONT PANIC SHELL)!
1 stars 1 forks source link

segfault when executing file after unset path #186

Closed JonasGoetz01 closed 6 months ago

JonasGoetz01 commented 6 months ago

touch tmp_x_file1 tmp_x_file1 echo $? ./tmp_x_file1 echo $? export PATH=$HOME echo $PATH tmp_x_file1 echo $? ./tmp_x_file1 echo $? unset PATH tmp_x_file1

when the files gets executed after the unset PATH I get a segfault

PaulicStudios commented 6 months ago
👤 vscode@
/workspaces/42-minishell ❯ tmp_x_file1 
Tokens:
Type: 0, Value: tmp_x_file1
Type: 15, Value:  
Tokens:
Type: 0, Value: tmp_x_file1
Type: 15, Value:  
AddressSanitizer:DEADLYSIGNAL
=================================================================
==78835==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x55e4601bfd05 bp 0x603000009d30 sp 0x7ffe55d0e210 T0)
==78835==The signal is caused by a READ memory access.
==78835==Hint: address points to the zero page.
    #0 0x55e4601bfd05 in remove_spaces_before_arguments src/input_parsing/remove_unused_spaces.c:92
    #1 0x55e4601c009d in remove_unused_spaces src/input_parsing/remove_unused_spaces.c:177
    #2 0x55e4601b88ed in process_input src/prompt/prompt.c:21
    #3 0x55e4601b8d09 in show_prompt src/prompt/prompt.c:133
    #4 0x55e4601b6643 in main src/main.c:51
    #5 0x7f79823cfd09 in __libc_start_main ../csu/libc-start.c:308
    #6 0x55e4601b6379 in _start (/workspaces/42-minishell/minishell+0x4379)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV src/input_parsing/remove_unused_spaces.c:92 in remove_spaces_before_arguments
==78835==ABORTING