Valgrind (spurious?) warning/error on exec
by penguin_quest from LinuxQuestions.org on (#6DE58)
Hi, I'm not sure if I'm using the exec* syscalls correctly. Valgrind gives me an error for this minimal example:
Code:#include <unistd.h>
int main() { execl("/bin/w", NULL); }Here is the error:
Code:==11213== Memcheck, a memory error detector
==11213== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==11213== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==11213== Command: ./test
==11213==
==11213== Syscall param execve(argv[0]) points to unaddressable byte(s)
==11213== at 0x496CB47: execve (syscall-template.S:120)
==11213== by 0x496CFB5: execl (execl.c:56)
==11213== by 0x109155: main (in /home/glt/git/wm/test)
==11213== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==11213==However, this semantically different variant gives no error:
Code:#include <unistd.h>
int main() { execl("/bin/w", "", NULL); }I thought that the first use above is correct, since the execl argument list is supposed to end with NULL. Is there another equivalent way that won't generate the Valgrind error? (It's annoying to have the spurious errors mixed in with actual program errors.) Thanks!
Code:#include <unistd.h>
int main() { execl("/bin/w", NULL); }Here is the error:
Code:==11213== Memcheck, a memory error detector
==11213== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==11213== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==11213== Command: ./test
==11213==
==11213== Syscall param execve(argv[0]) points to unaddressable byte(s)
==11213== at 0x496CB47: execve (syscall-template.S:120)
==11213== by 0x496CFB5: execl (execl.c:56)
==11213== by 0x109155: main (in /home/glt/git/wm/test)
==11213== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==11213==However, this semantically different variant gives no error:
Code:#include <unistd.h>
int main() { execl("/bin/w", "", NULL); }I thought that the first use above is correct, since the execl argument list is supposed to end with NULL. Is there another equivalent way that won't generate the Valgrind error? (It's annoying to have the spurious errors mixed in with actual program errors.) Thanks!