Subject: Re: compat_linux on amd64 report
To: Emmanuel Dreyfus <manu@NetBSD.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: port-amd64
Date: 11/21/2005 13:36:49
--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Nov 18, 2005 at 04:25:59PM +0000, Emmanuel Dreyfus wrote:
> Hello
> 
> Linux java and javac now seem to work on NetBSD/amd64. I'd appreciate
> feedback from users there are always bugs difficult to spot).

I'm getting bad behaviour with small threaded programs (not really
linux java related, but ...).

njoly@lanfeust [~]> uname -a
NetBSD lanfeust.sis.pasteur.fr 3.99.11 NetBSD 3.99.11 (LANFEUST) #2: Mon Nov 21 11:01:56 CET 2005  njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64

njoly@lanfeust [~]> sysctl -a | grep linux
emul.linux.kern.ostype = Linux
emul.linux.kern.osrelease = 2.6.9
emul.linux.kern.osversion = #0 Wed Feb 20 20:00:02 CET 2002
njoly@lanfeust [tmp/threads]> file thr_linux
thr_linux: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
njoly@lanfeust [tmp/threads]> ./thr_linux
thr_linux: pthread_create: Cannot allocate memory
njoly@lanfeust [tmp/threads]> ktruss ./thr_linux
[...]
  1172 thr_linux getrlimit(0x3, 0x7f7fffffe258)    = 0
  1172 thr_linux __sysctl(0x7f7fffffdfb8)          = 0
  1172 thr_linux mmap(0, 0x200000000200000, 0x3, 0x62, 0xffffffff, 0) Err#12 ENOMEM
  1172 thr_linux mmap(0, 0x200000000200000, 0x7, 0x22, 0xffffffff, 0) Err#12 ENOMEM
  1172 thr_linux write(0x2, 0x7f7fffffb9c0, 0xb)
  1172 thr_linux write                             = 11
[...]

The mmap(2) size argument looks incorrect ...

This program was compiled on a CentOS 4.2 (RHEL clone) x86_64
machine. It seems to be an amd64 linux compat issue as the same
program runs fine on NetBSD/i386 using linux emulation.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="thr.c"

#include <stdio.h>
 
#include <pthread.h>

void *thr_run(void *);    


int main(int argc, char **argv) {
  pthread_t thr;
  
  if (pthread_create(&thr, NULL, thr_run, NULL) != 0) {
    err(1, "pthread_create"); }
  
  (void)printf("main hello world\n");  

  if (pthread_join(thr, NULL) != 0) {
    err(1, "pthread_join"); }
  
  return 0; }
 
 
void *thr_run(void *arg) {
 
  (void)printf("thread hello world\n");
  
  return NULL; }


--ew6BAiZeqk4r7MaW--