| Summary: | Failure on the Yosys project: valgrind: m_libcfile.c:1802 (Bool vgPlain_realpath(const HChar *, HChar *)): Assertion 'resolved' failed. | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Yuri <yuri> |
| Component: | general | Assignee: | Paul Floyd <pjfloyd> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | pjfloyd |
| Priority: | NOR | ||
| Version First Reported In: | 3.21.0 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | FreeBSD | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Yuri
2023-06-06 18:43:27 UTC
I'm not handling a NULL for returned_path https://man.freebsd.org/cgi/man.cgi?query=realpath&sektion=3&format=html Though I thought libc was supost to allocate memory if it's NULL. Ah but it's not using realpath. https://github.com/YosysHQ/yosys/blob/5813809ad9afbe1c38f65c6aae7c3441d7614d0b/kernel/yosys.cc#L890 #elif defined(__FreeBSD__) std::string proc_self_dirname() { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; size_t buflen; char *buffer; std::string path; if (sysctl(mib, 4, NULL, &buflen, NULL, 0) != 0) log_error("sysctl failed: %s\n", strerror(errno)); buffer = (char*)malloc(buflen); if (buffer == NULL) log_error("malloc failed: %s\n", strerror(errno)); if (sysctl(mib, 4, buffer, &buflen, NULL, 0) != 0) log_error("sysctl failed: %s\n", strerror(errno)); while (buflen > 0 && buffer[buflen-1] != '/') buflen--; path.assign(buffer, buflen); free(buffer); return path; } There are two calls to sysctl kern.proc.pathname, one to get the buffer size and one to get the pathname. commit 840ccb9915c675fd7db527107e6b38343fafdf86 (HEAD -> master, origin/master, origin/HEAD) Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Wed Jun 7 22:27:08 2023 +0200 Bug 470713 - Failure on the Yosys project: valgrind: m_libcfile.c:1802 (Bool vgPlain_realpath(const HChar *, HChar *)): Assertion 'resolved' failed When using sysctl kern proc pathname with the pid of the guest or -1 we need to intercept the call otherwise the syscall will return the path of the memcheck tool and not the path of the guest. This uses VG_(realpath), which asserts if it doesn't get valid input pointers. sysctl kern proc pathname can use a NULL pointer in order to determine the length of the path (so users can allocate the minumum necessary). The NULL pointer was being passed on to VG_(realpath) without being checked, resulting in an assert. Should be fixed with the above change. Can you build Valgrind from source and test it? Otherwise I'll do a test with Yosys. Rather try this as I made one mistake commit 8bc3a55d50570ef3e3077a7bdfb6354895a56878 (HEAD -> master, origin/master, origin/HEAD) Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Wed Jun 7 22:54:22 2023 +0200 Merge error, missing continuation in Makefile.am I tried with the yosys port, and it now gets to the command prompt. |