Subject: sigbus test fails
From: Gordan Bobic <gordan@bobich.net>
Date: Mon, 21 Feb 2011 20:53:57 +0000

Hi,

I've mostly got vserver working on ARM, but until now, only with glibc. 
As of some time today, however, dietlibc now successfully builds on ARM 
without any errors and util-vserver builds against it. However, one of 
the tests is failing - sigbus.

/bin/sh: line 4: 25632 Bus error 
ensc_use_expensive_tests="no" ensc_test_debug="no" 
srctestsuitedir=./src/testsuite 
libinternaltestsuitedir=./lib_internal/testsuite ${dir}$tst
FAIL: lib_internal/testsuite/sigbus

I tried all recent versions from util-vserver-0.30.216-pre2914 onward, 
and the same thing happens on all of them (this particular strace and 
backtrace are from pre2914, I've been going backwards so that's what I 
have handy right now).

This is what I get when I strace lib_internal/testsuite/sigbus

# strace ./sigbus
execve("./sigbus", ["./sigbus"], [/* 27 vars */]) = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "\f\277%\365", 4)               = 4
open("/tmp/sigbus.cofbiq", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = 4
close(3)                                = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "u\31y\202", 4)                 = 4
open("/tmp/sigbus.lb6i71", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = 5
close(3)                                = 0
write(4, 
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
73728) = 73728
close(4)                                = 0
close(5)                                = 0
unlink("/tmp/sigbus.lb6i71")            = 0
stat64("/tmp/sigbus.cofbiq", {st_mode=S_IFREG|0600, st_size=73728, ...}) = 0
open("/tmp/sigbus.cofbiq", 
O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = 3
open("/tmp/sigbus.lb6i71", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_LARGEFILE, 
0200) = 4
fstat64(3, {st_mode=S_IFREG|0600, st_size=73728, ...}) = 0
rt_sigaction(SIGBUS, {0x85f8, [BUS], SA_NODEFER}, {SIG_DFL, [], 0}, 8) = 0
_llseek(3, 0, [73728], SEEK_END)        = 0
ftruncate64(4, 316659348799488)         = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
mmap2(NULL, 73728, PROT_READ, MAP_SHARED, 3, 0) = 0x40090000
mmap2(NULL, 73728, PROT_WRITE, MAP_SHARED, 4, 0) = 0x40194000
madvise(0x40090000, 73728, MADV_SEQUENTIAL) = 0
madvise(0x40194000, 73728, MADV_SEQUENTIAL) = 0
munmap(0x40194000, 73728)               = 0
munmap(0x40090000, 73728)               = 0
rt_sigaction(SIGBUS, {SIG_DFL, [BUS], SA_NODEFER}, {0x85f8, [BUS], 
SA_NODEFER}, 8) = 0
close(4)                                = 0
close(3)                                = 0
socketpair(PF_FILE, SOCK_STREAM, 0, [3, 4]) = 0
rt_sigaction(SIGCHLD, {SIG_IGN, [CHLD], SA_NODEFER}, {SIG_DFL, [], 0}, 
8) = 0
fork()                                  = 26321
unlink("/tmp/sigbus.lb6i71")            = 0
open("/tmp/sigbus.cofbiq", 
O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = 5
open("/tmp/sigbus.lb6i71", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_LARGEFILE, 
0200) = 6
fstat64(5, {st_mode=S_IFREG|0600, st_size=73728, ...}) = 0
rt_sigaction(SIGBUS, {0x85f8, [BUS], SA_NODEFER}, {SIG_DFL, [BUS], 
SA_NODEFER}, 8) = 0
_llseek(5, 0, [73728], SEEK_END)        = 0
ftruncate64(6, 316659348799488)         = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
mmap2(NULL, 73728, PROT_READ, MAP_SHARED, 5, 0) = 0x4001b000
mmap2(NULL, 73728, PROT_WRITE, MAP_SHARED, 6, 0) = 0x400cf000
madvise(0x4001b000, 73728, MADV_SEQUENTIAL) = 0
madvise(0x400cf000, 73728, MADV_SEQUENTIAL) = 0
send(4, ".", 1, 0)                      = 1
recv(4, ".", 1, 0)                      = 1
--- SIGBUS (Bus error) @ 0 (0) ---
munmap(0x400cf000, 73728)               = 0
munmap(0x4001b000, 73728)               = 0
rt_sigaction(SIGBUS, {SIG_DFL, [BUS], SA_NODEFER}, {0x85f8, [BUS], 
SA_NODEFER}, 8) = 0
close(6)                                = 0
close(5)                                = 0
fork()                                  = 26322
unlink("/tmp/sigbus.lb6i71")            = 0
open("/tmp/sigbus.cofbiq", 
O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = 5
open("/tmp/sigbus.lb6i71", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_LARGEFILE, 
0200) = 6
fstat64(5, {st_mode=S_IFREG|0600, st_size=36864, ...}) = 0
rt_sigaction(SIGBUS, {0x85f8, [BUS], SA_NODEFER}, {SIG_DFL, [BUS], 
SA_NODEFER}, 8) = 0
_llseek(5, 0, [36864], SEEK_END)        = 0
ftruncate64(6, 158329674399744)         = 0
rt_sigprocmask(SIG_BLOCK, NULL, [BUS], 8) = 0
mmap2(NULL, 36864, PROT_READ, MAP_SHARED, 5, 0) = 0x40090000
mmap2(NULL, 36864, PROT_WRITE, MAP_SHARED, 6, 0) = 0x400e8000
madvise(0x40090000, 36864, MADV_SEQUENTIAL) = 0
madvise(0x400e8000, 36864, MADV_SEQUENTIAL) = 0
send(4, ".", 1, 0)                      = 1
recv(4, ".", 1, 0)                      = 1
--- SIGBUS (Bus error) @ 0 (0) ---
+++ killed by SIGBUS +++
Bus error


Does that look sane?

This is the backtrace I get in the core:

# gdb --quiet sigbus core.26591
Reading symbols from 
/usr/src/redhat/BUILD/util-vserver-0.30.216-pre2926/lib_internal/testsuite/sigbus...done.
[New Thread 26591]
Core was generated by `./sigbus'.
Program terminated with signal 7, Bus error.
#0  copyMem (in_fd=0, out_fd=0) at lib_internal/testsuite/../unify-copy.c:95
95	    if (*src != 0) *dst = *src;
(gdb) backtrace
#0  copyMem (in_fd=0, out_fd=0) at lib_internal/testsuite/../unify-copy.c:95
#1  copyMMap (in_fd=0, out_fd=0) at 
lib_internal/testsuite/../unify-copy.c:146
#2  0x00008578 in copyReg (src=<value optimized out>, src_stat=<value 
optimized out>, dst=<value optimized out>) at 
lib_internal/testsuite/../unify-copy.c:186
#3  0x000086e4 in checkTrunc (src=0xbe9726b8 "/tmp/sigbus.64k1rk", 
dst=0xbe9726a4 "/tmp/sigbus.91ikm8", st=0xbe972638, pos=9029) at 
lib_internal/testsuite/sigbus.c:76
#4  0x0000886c in main () at lib_internal/testsuite/sigbus.c:105


Can somebody more familiar with the code hazard a guess as to what is 
actually breaking here? I am guessing it is a bug in dietlibc somewhere, 
but helping to pin it down to the relevant library call would be really 
appreciated.

TIA.

Gordan