Hello,

I am having trouble running programs that need to use "ulimit" under valgrind. 
For instance, here is a simple script that changes the limit of open files to 
100000. All commands below are executed as root:

> cat foo
#!/bin/sh
ulimit -n 100000

I can run it fine on its own.

> ./foo
> echo $?
0

But under valgrind I get blocked with "Operation not permitted":

> valgrind ./foo
==729== Memcheck, a memory error detector
==729== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==729== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==729== Command: ./foo
==729== 
./foo: line 2: ulimit: open files: cannot modify limit: Operation not permitted
==729== 
==729== HEAP SUMMARY:
==729==     in use at exit: 22,355 bytes in 579 blocks
==729==   total heap usage: 689 allocs, 110 frees, 34,516 bytes allocated
==729== 
==729== LEAK SUMMARY:
==729==    definitely lost: 0 bytes in 0 blocks
==729==    indirectly lost: 0 bytes in 0 blocks
==729==      possibly lost: 0 bytes in 0 blocks
==729==    still reachable: 22,355 bytes in 579 blocks
==729==         suppressed: 0 bytes in 0 blocks
==729== Rerun with --leak-check=full to see details of leaked memory
==729== 
==729== For counts of detected and suppressed errors, rerun with: -v
==729== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

Right now I have no entries in /etc/security/limits.conf, however it looks like 
the file is not even accessed:

> strace -s 100 -f /usr/bin/valgrind ./foo > trace 2>&1
> grep limits.conf trace
> echo $?
1

Any hints will be much appreciated.

My platform is 64-bit Linux.


Thank you,
Costas


PS: Here is part of the trace I took above. Maybe it is obvious to someone what 
goes wrong:

read(255, "#!/bin/sh\nulimit -n 100000\n", 27) = 27
rt_sigprocmask(SIG_SETMASK, ~[ILL TRAP BUS FPE KILL SEGV STOP], NULL, 8) = 0
gettid()                                = 784
read(1027, "G", 1)                      = 1
rt_sigprocmask(SIG_SETMASK, ~[], ~[ILL TRAP BUS FPE KILL SEGV STOP], 8) = 0
rt_sigtimedwait(~[], 0x4029a1d00)       = -1 EAGAIN (Resource temporarily 
unavailable)
rt_sigprocmask(SIG_SETMASK, ~[ILL TRAP BUS FPE KILL SEGV STOP], NULL, 8) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1034, rlim_max=8*1024}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1034, rlim_max=8*1024}) = 0
fstat(2, {st_mode=S_IFREG|0644, st_size=129020, ...}) = 0
mmap(0x4028000, 4096, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4028000
gettid()                                = 784
write(1028, "H", 1)                     = 1
rt_sigprocmask(SIG_SETMASK, [], ~[ILL TRAP BUS FPE KILL SEGV STOP], 8) = 0
write(2, "./foo: line 2: ulimit: open files: cannot modify limit: Operation not 
permitted\n", 80./foo: line 2: ulimit: open files: cannot modify limit: 
Operation not permitted) = 80



------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to