Subject: setrlimit(2) strange behaviour under compat_netbsd32
To: NetBSD current <current-users@NetBSD.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 11/20/2006 20:42:53
Hi,

I just noticed a strange setrlimit(2) behaviour under compat_netbsd32
(and compat_linux32) on my -current amd64 workstation ...

It seems that 32bits programs, running under compat_netbsd32, using
setrlimit force all other programs to have their maximum data size
fixed at 3GB, where native 64bits apps used 8GB previously.

njoly@lanfeust [tmp/limits]> file limits limits.netbsd32
limits:          ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), for Ne
tBSD 4.99.4, dynamically linked (uses shared libs), not stripped
limits.netbsd32: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), for N
etBSD 4.99.4, dynamically linked (uses shared libs), not stripped

njoly@lanfeust [tmp/limits]> ./limits
pid = 367
soft = 268435456, hard = 8589934592
soft = 1221225472, hard = 1221225472
njoly@lanfeust [tmp/limits]> ./limits.netbsd32
pid = 948
soft = 268435456, hard = 3221225472
soft = 1221225472, hard = 1221225472
njoly@lanfeust [tmp/limits]> ./limits
pid = 1719
soft = 268435456, hard = 3221225472
soft = 1221225472, hard = 1221225472

njoly@lanfeust [tmp/limits]> cat limits.c
#include <sys/resource.h>
#include <err.h>
#include <stdio.h>
#include <unistd.h>

int main() {
  int i;
  struct rlimit rlp;

  printf("pid = %d\n", getpid());

  i = getrlimit(RLIMIT_DATA, &rlp);
  if (i == -1)
    err(1, "getrlimit failed");
  printf("soft = %lu, hard = %lu\n", rlp.rlim_cur, rlp.rlim_max);

  rlp.rlim_cur = rlp.rlim_max = 1221225472;
  i = setrlimit(RLIMIT_DATA, &rlp);
  if (i == -1)
    err(1, "setrlimit failed");

  i = getrlimit(RLIMIT_DATA, &rlp);
  if (i == -1)
    err(1, "getrlimit failed");
  printf("soft = %lu, hard = %lu\n", rlp.rlim_cur, rlp.rlim_max);

  return 0; }

Did i missed something, or setrlimit is doing something wrong under
compat_netbsd32 ?

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.