Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ktrace(1) makes compat linux32 processes crash on amd64



Hi,

I'm experiencing some problems with processes that run under compat
linux32 emulation ... And especially under ktrace(1).

A simple program that prints `Hello World' can trigger it ...

njoly@lanfeust [~]> file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 
2.4.1, dynamically linked (uses shared libs), not stripped

njoly@lanfeust [~]> ./hello 
Hello World
njoly@lanfeust [~]> ktrace ./hello
Hello World
njoly@lanfeust [~]> ktrace -i ./hello
Hello World
njoly@lanfeust [~]> ktrace -d ./hello
zsh: segmentation fault (core dumped)  ktrace -d ./hello

This does not like as simple, as sometimes it works.

njoly@lanfeust [~]> i=0; while :; do ktrace -d ./hello && break; i=`expr $i + 
1`; done && echo $i 
Hello World
991
njoly@lanfeust [~]> i=0; while :; do ktrace -d ./hello && break; i=`expr $i + 
1`; done && echo $i 
Hello World
1559

All failure (not only with this small testcase) cases seems to show a
mmap problem, returning ENOMEM, when loading dynamic libraries:

njoly@lanfeust [~]> /emul/linux32/usr/bin/ldd ./hello
         (0xffffe950)
        libc.so.6 => /lib/libc.so.6 (0xfbec2000)
        /lib/ld-linux.so.2 (0xfbfe8000)
njoly@lanfeust [~]> ktrace -d ./hello
zsh: segmentation fault (core dumped)  ktrace -d ./hello
njoly@lanfeust [~]> kdump | grep mmap
 10208      1 hello    CALL  old_mmap(0xff29e1bc)
 10208      1 hello    RET   old_mmap -1 errno -12 Cannot allocate memory
 10208      1 hello    CALL  old_mmap(0xff29e114)
 10208      1 hello    RET   old_mmap -1 errno -12 Cannot allocate memory

A quick check, shows that the ENOMEM error comes from
uvm_map_prepare() with uvm_map_findspace() returning NULL.

I'm not sure what's going on there, but it worked before (sorry, i
don't have a date handy).

Any idea where to look for ?
Thanks.

NB: When raising shell limits up to their maximum, the symptoms are
different. I can't even see the traced process.

njoly@lanfeust [~]> ktrace -d ./hello
zsh: abort      ktrace -d ./hello
njoly@lanfeust [~]> kdump
 17234      1 ktrace   EMUL  "netbsd"
 17234      1 ktrace   RET   ktrace 0
 17234      1 ktrace   CALL  
execve(0x7f7ffffffcb2,0x7f7fffffdaa8,0x7f7fffffdab8)
 17234      1 ktrace   NAMI  "./hello"
 17234      1 ktrace   NAMI  "/emul/linux32"
 17234      1 ktrace   NAMI  "/emul/linux32/lib/ld-linux.so.2"
njoly@lanfeust [~]> 

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.


Home | Main Index | Thread Index | Old Index