Date: Sun, 13 Nov 2022 22:21:34 +0000 From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 267752] devel/valgrind: Valgrind fails on programs compiled with -fsanitize=address Message-ID: <bug-267752-7788-XxabUtEUfi@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-267752-7788@https.bugs.freebsd.org/bugzilla/> References: <bug-267752-7788@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D267752 --- Comment #4 from Paul Floyd <pjfloyd@wanadoo.fr> --- 'valgrind' is just a small exe. It modifies the environment to add some LD_PRELOADs and adds an env var called VALGRIND_LAUNCHER. Then it execs the tool (memcheck-amd64-freebsd for instance). The tool code that fails is VG_(debugLog)(1, "main", "Getting launcher's name ...\n"); VG_(name_of_launcher) =3D VG_(getenv)(VALGRIND_LAUNCHER); if (VG_(name_of_launcher) =3D=3D NULL) { VG_(printf)("valgrind: You cannot run '%s' directly.\n", argv[0]); VG_(printf)("valgrind: You should use $prefix/bin/valgrind.\n"); VG_(exit)(1); } And here is the launcher code /* Figure out the name of this executable (viz, the launcher), so we can tell stage2. stage2 will use the name for recursive invocations of valgrind on child processes. */ memset(launcher_name, 0, PATH_MAX+1); oid[0] =3D CTL_KERN; oid[1] =3D KERN_PROC; oid[2] =3D KERN_PROC_PATHNAME; oid[3] =3D getpid(); len =3D PATH_MAX; r =3D sysctl(oid, 4, launcher_name, &len, 0, 0); if (r !=3D 0) { fprintf(stderr, "valgrind: warning (non-fatal): " "sysctl(\"kern.proc.pathname\") failed.\n"); fprintf(stderr, "valgrind: continuing, however --trace-children=3Dyes= " "will not work.\n"); } /* tediously augment the env: VALGRIND_LAUNCHER=3Dlauncher_name */ new_line =3D malloc(strlen(VALGRIND_LAUNCHER) + 1 + strlen(launcher_name) + 1); if (new_line =3D=3D NULL) barf("malloc of new_line failed."); strcpy(new_line, VALGRIND_LAUNCHER); strcat(new_line, "=3D"); strcat(new_line, launcher_name); for (j =3D 0; envp[j]; j++) ; new_env =3D malloc((j+2) * sizeof(char*)); Does your exe run a bit and then fork/exec? You you set --trace-children=3Dyes (in your valgrind ini file)? I don't know how the sanitized exe is interfering with this, it is all well before the guest even gets loaded. Either the sysctl isn't working correctl= y or the env var is getting corrupted. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-267752-7788-XxabUtEUfi>