valgrind gets fatal signal when particular syscall is made by an executable
Daniel Fishman <[email protected]> Sun, 2 Jul 2023 14:35:20 +0300
| Newsgroups | gmane.comp.debugging.valgrind |
|---|---|
| Message-ID | <CAEZK+0VK2TTWu8Z_qVN2Ox8JTMSkv0YABHcYpU1B7gE43OWckQ@mail.gmail.com> |
Hello, On a machine that has an old linux kernel, when valgrind 3.21.0 runs an executable that contains a call to syscall 378 - valgrind fails after being killed by a fatal signal. The kernel on the machine is 3.10.0 x86_64 (the system is based on RedHad 5, I think), libc 2.17, and the executable itself is 32 bit. On this particular kernel, syscall 378 happens to be mapped to setprocns, while valgrind thinks that an executable is trying to execute syscall preadv2, which is indeed mapped to 378 on newer kernels, but doesn't exist in linux 3.10.0 Older versions of valgrind (for example, valgrind 3.10.0) don't have this problem, and succeed to execute the same executable on this machine. According to release notes it seems that this platform is supported. What can I do to fix the problem? Unfortunately I am stuck with having to use such an old system, and therefore using newer kernel is not an option. Test program and valgrind's report with the fatal signal are attached. gcc 6.3.0 was used for compilations (both the executable and the valgrind). _______________________________________________ Valgrind-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/valgrind-users
report.log
(application/octet-stream, 2.9 KB)
==24250== Memcheck, a memory error detector ==24250== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==24250== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info ==24250== Command: ./a ==24250== Parent PID: 18905 ==24250== ==24250== Warning: client switching stacks? SP change: 0xfea8ee10 --> 0x4024f9c ==24250== to suppress, use: --max-stackframe=89743756 or greater ==24250== Warning: client switching stacks? SP change: 0x4024f9c --> 0xfea8ee10 ==24250== to suppress, use: --max-stackframe=89743756 or greater ==24250== Syscall param open(mode) contains uninitialised byte(s) ==24250== at 0x4136083: __open_nocancel (in /usr/lib/libc-2.17.so) ==24250== by 0x80485EA: main (in /home/admin/a) ==24250== ==24250== Syscall param preadv2(offset_low) contains uninitialised byte(s) ==24250== at 0x41432C7: syscall (in /usr/lib/libc-2.17.so) ==24250== by 0x8048628: main (in /home/admin/a) ==24250== ==24250== Syscall param preadv2(offset_high) contains uninitialised byte(s) ==24250== at 0x41432C7: syscall (in /usr/lib/libc-2.17.so) ==24250== by 0x8048628: main (in /home/admin/a) ==24250== ==24250== Syscall param preadv2(flags) contains uninitialised byte(s) ==24250== at 0x41432C7: syscall (in /usr/lib/libc-2.17.so) ==24250== by 0x8048628: main (in /home/admin/a) ==24250== --24250-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting --24250-- si_code=1; Faulting address: 0x8; sp: 0x82ecad58 valgrind: the 'impossible' happened: Killed by fatal signal host stacktrace: ==24250== at 0x58140BB4: handle_pre_sys_preadv (syswrap-linux.c:6132) ==24250== by 0x581410B2: vgSysWrap_linux_sys_preadv2_before (syswrap-linux.c:6222) ==24250== by 0x580CAA89: vgPlain_client_syscall (syswrap-main.c:2240) ==24250== by 0x580C5BE7: handle_syscall (scheduler.c:1206) ==24250== by 0x580C87D6: vgPlain_scheduler (scheduler.c:1552) ==24250== by 0x5811F73C: thread_wrapper (syswrap-linux.c:102) ==24250== by 0x5811F73C: run_a_thread_NORETURN (syswrap-linux.c:155) sched status: running_tid=1 Thread 1: status = VgTs_Runnable syscall 378 (lwpid 24250) ==24250== at 0x41432C7: syscall (in /usr/lib/libc-2.17.so) ==24250== by 0x8048628: main (in /home/admin/a) client stack range: [0xFEA8D000 0xFEA90FFF] client SP: 0xFEA8FEE8 valgrind stack range: [0x82DCB000 0x82ECAFFF] top usage: 6836 of 1048576 Note: see also the FAQ in the source distribution. It contains workarounds to several common problems. In particular, if Valgrind aborted or crashed after identifying problems in your program, there's a good chance that fixing those problems will prevent Valgrind aborting or crashing, especially if it happened in m_mallocfree.c. If that doesn't help, please report this bug to: www.valgrind.org In the bug report, send all the above text, the valgrind version, and what OS and version you are using. Thanks.
a.c
(application/octet-stream, 367 B)
#define _GNU_SOURCE
#include <linux/sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
int main()
{
int fd, ret;
if ((fd = open("./test", O_RDONLY|O_CREAT)) < 0)
{
printf("failed to open file");
exit(1);
}
ret = syscall(378, getpid(), fd, CLONE_NEWNET);
if (!ret)
{
printf("syscall failed");
}
}