|
From: Julian S. <se...@so...> - 2020-01-02 13:27:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2a7d3ae768f9e5b29acd5cb743c3fb13640a391c commit 2a7d3ae768f9e5b29acd5cb743c3fb13640a391c Author: Julian Seward <js...@ac...> Date: Thu Jan 2 14:27:24 2020 +0100 sys_statx: don't complain if both |filename| and |buf| are NULL. So as to work around the Rust library's dubious use of statx. Diff: --- coregrind/m_syswrap/syswrap-linux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 87c513a..96c309e 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -3692,10 +3692,19 @@ PRE(sys_statx) PRINT("sys_statx ( %ld, %#" FMT_REGWORD "x(%s), %ld, %ld, %#" FMT_REGWORD "x )", (Word)ARG1,ARG2,(char*)(Addr)ARG2,(Word)ARG3,(Word)ARG4,ARG5); PRE_REG_READ5(long, "statx", - int, dirfd, char *, file_name, int, flags, + int, dirfd, char *, filename, int, flags, unsigned int, mask, struct statx *, buf); - PRE_MEM_RASCIIZ( "statx(file_name)", ARG2 ); - PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) ); + // Work around Rust's dubious use of statx, as described here: + // https://github.com/rust-lang/rust/blob/ + // ccd238309f9dce92a05a23c2959e2819668c69a4/ + // src/libstd/sys/unix/fs.rs#L128-L142 + // in which it passes NULL for both filename and buf, and then looks at the + // return value, so as to determine whether or not this syscall is supported. + Bool both_filename_and_buf_are_null = ARG2 == 0 && ARG5 == 0; + if (!both_filename_and_buf_are_null) { + PRE_MEM_RASCIIZ( "statx(filename)", ARG2 ); + PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) ); + } } POST(sys_statx) { |