svn2github / valgrind

This is a clone of an SVN repository at svn://svn.valgrind.org/valgrind/trunk. It had been cloned by http://svn2github.com/ , but the service was since closed. Please read a closing note on my blog post: http://piotr.gabryjeluk.pl/blog:closing-svn2github . If you want to continue synchronizing this repo, look at https://github.com/gabrys/svn2github

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setrlimit with RLIMIT_NOFILE failing with Operation not permitted

udaykkumar opened this issue · comments

commented

I'm not sure if there is some wrong with what I've been doing it here
This piece of code is not really working as expected when run under valgrind

int main()
{
        const struct rlimit file_limits = { .rlim_cur = 65536, .rlim_max = 65536 };
        if ( setrlimit( RLIMIT_NOFILE, &file_limits ) )
        {
                printf(" Failed  %d", errno );
                perror(" More " );
        }
        else
        {
                printf(" Success ");
        }
        return 0;
}
  • run as root user
[root@localhost kk]# ulimit -H -n
800000
[root@localhost kk]# ulimit -S -n
500000
[root@localhost kk]# ./rlimit
 Success
[root@localhost kk]#
  • run as root user under valgrind
[root@localhost kk]# ulimit -S -n
500000
[root@localhost kk]# ulimit -H -n
800000
[root@localhost kk]#  valgrind ./a.out
==498== Memcheck, a memory error detector
==498== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==498== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==498== Command: ./a.out
==498==
 More : Operation not permitted
 Failed -1 1==498==
==498== HEAP SUMMARY:
==498==     in use at exit: 0 bytes in 0 blocks
==498==   total heap usage: 1 allocs, 1 frees, 568 bytes allocated
==498==
==498== All heap blocks were freed -- no leaks are possible
==498==
==498== For counts of detected and suppressed errors, rerun with: -v
==498== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
[root@localhost kk]#

Here are some more additional information

[root@localhost kk]# uname -a
Linux localhost 3.10.0-693.21.1.el7.hpsp.centos.49772.x86_64 #1 SMP Tue Jul 24 13:26:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost kk]# cat /etc/redhat-release
CentOS release 7.4 (Final)
[root@localhost kk]# valgrind --version
valgrind-3.12.0
[root@localhost kk]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
[root@localhost kk]# ldd -v
ldd: missing file arguments
Try `ldd --help' for more information.
[root@localhost kk]# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
[root@localhost kk]#

Any hints on this ?