|
From: Matthias S. <zz...@ge...> - 2012-02-09 20:38:28
Attachments:
valgrind-12373-prlimit64-improved.patch
|
Hi all, I tried to run a win32 application under valgrind+wine on a gentoo x86 installation. Sadly this failed on an internal error like in https://bugs.kde.org/show_bug.cgi?id=275673 The error looks like this part from the bug: strace.txt:61324:[pid 2563] pipe([20, 21]) = 0 strace.txt:61325:[pid 2563] fcntl(20, F_DUPFD, 1014) = -1 EINVAL (Invalid argument) strace.txt:61327:[pid 2563] gettid() = 2563 strace.txt:61408:[pid 2563] fcntl(-1, F_SETFD, FD_CLOEXEC) = -1 EBADF (Bad file descriptor) strace.txt:61413:[pid 2563] gettid() = 2563 strace.txt:61509:[pid 2563] poll([{fd=1019, events=POLLIN}], 1, -1 The duplicating of the fd fails. The reason is, that before prlimit64 is called to change RLIMIT_NOFILE. But valgrind does not emulate it like setrlimit and getrlimit. (The second call to set FD_CLOEXEC could be avoided on error of F_DUPFD before.) I changed valgrind to make prlimit64 behave like the setrlimit and getrlimit syscalls. The patch also contains a testcase for setrlimit64 and getrlimit64 for fileno. I needed to move all code to the pre-handler, as it is possible to call prlimit64 with both set and get parameter. This also deserves a testcase. What also is missing is: only using the emulation if pid is 0 or equal the current pid. The attached patch applies against valgrind svn revision 12373. Tested on a Gentoo amd64 installation built for 64bit and also built for 32bit (with --enable-only32bit). Regards, Matthias |
|
From: Tom H. <to...@co...> - 2012-02-10 00:21:55
|
On 09/02/12 20:36, Matthias Schwarzott wrote: > The attached patch applies against valgrind svn revision 12373. > Tested on a Gentoo amd64 installation built for 64bit and also built for > 32bit (with --enable-only32bit). Please open a bug in the bug tracker and attach your patch to it so that it doesn't get lost. Tom -- Tom Hughes (to...@co...) http://compton.nu/ |
|
From: Matthias S. <zz...@ge...> - 2012-02-18 10:16:59
|
On 10.02.2012 01:21, Tom Hughes wrote: > On 09/02/12 20:36, Matthias Schwarzott wrote: > >> The attached patch applies against valgrind svn revision 12373. >> Tested on a Gentoo amd64 installation built for 64bit and also built for >> 32bit (with --enable-only32bit). > > Please open a bug in the bug tracker and attach your patch to it so > that it doesn't get lost. > > Tom > I created https://bugs.kde.org/show_bug.cgi?id=294047 and attached a new version of the patch there. The attached patch does this: Change prlimit64 to behave like a combination of the existing setrlimit and getrlimit. Run emulation only if ARG0 (pid) is 0 or equal getpid() improve setrlimit (like new prlimit64) to return EINVAL if softlimit>hardlimit Add tests (using getrlimit64 and setrlimit64) TODO: Tests using prlimit and prlimit64 (perhaps with different pid values) on x86: getrlimit -> syscall getrlimit setrlimit -> syscall setrlimit prlimit -> syscall prlimit64 getrlimit64 -> syscall prlimit64 setrlimit64 -> syscall prlimit64 prlimit64 -> syscall prlimit64 on amd64: getrlimit -> syscall getrlimit setrlimit -> syscall setrlimit prlimit -> syscall prlimit64 getrlimit64 -> syscall getrlimit setrlimit64 -> syscall setrlimit prlimit64 -> syscall prlimit64 Regards Matthias |