Who understands this code?

Greg Schafer gschafer at zip.com.au
Thu Mar 13 23:23:47 PST 2003


On Fri, Mar 14, 2003 at 04:04:27PM +1100, Greg Schafer wrote:
> Don, both tests are being done inside a chroot. One fails, one doesn't.
> One is an early chroot (kernel headers, glibc, binutils + Ch 5 stuff), one
> is a full system. :-/
> 
> For the record, my logs dating back to Aug 2002 with gcc-3.1.1 also confirm
> the problem back then.

Ok, this HAS to be some sort of glibc bug. Check this out:-

root:~# ldconfig
root:~# ./a.out
test 3 nonconsecutive pages - 40014000, 40149000
root:~# rm /etc/ld.so.cache
root:~# ./a.out
root:~# ldconfig
root:~# ./a.out
test 3 nonconsecutive pages - 40014000, 40149000

So, rm'ing /etc/ld.so.cache fixes it! ?? Maybe the tiny ld.so.cache in early
phase of chroot is triggering the bug and later on when we have more libs
and the size of ld.so.cache grows the bug doesn't show up?

Weird, very weird.. I don't fancy explaining this one to the glibc guys. Any
takers? :-)

Strace logs attached.

Greg
-------------- next part --------------
execve("./a.out", ["./a.out"], [/* 8 vars */]) = 0
uname({sys="Linux", node="tigers-lfs", ...}) = 0
brk(0)                                  = 0x8049a04
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/lib/i686/mmx/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/i686/mmx", 0xbffff160)     = -1 ENOENT (No such file or directory)
open("/lib/i686/libc.so.6", O_RDONLY)   = -1 ENOENT (No such file or directory)
stat64("/lib/i686", 0xbffff160)         = -1 ENOENT (No such file or directory)
open("/lib/mmx/libc.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)
stat64("/lib/mmx", 0xbffff160)          = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340[\1"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1263608, ...}) = 0
mmap2(NULL, 1254820, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40014000
mprotect(0x4013f000, 30116, PROT_NONE)  = 0
mmap2(0x4013f000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12a) = 0x4013f000
mmap2(0x40144000, 9636, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40144000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40147000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40148000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40149000
semget(IPC_PRIVATE, 0, 0)               = -1 ENOSYS (Function not implemented)
_exit(0)                                = ?
-------------- next part --------------
execve("./a.out", ["./a.out"], [/* 8 vars */]) = 0
uname({sys="Linux", node="tigers-lfs", ...}) = 0
brk(0)                                  = 0x8049a04
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3102, ...}) = 0
mmap2(NULL, 3102, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40014000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340[\1"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1263608, ...}) = 0
mmap2(NULL, 1254820, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40015000
mprotect(0x40140000, 30116, PROT_NONE)  = 0
mmap2(0x40140000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12a) = 0x40140000
mmap2(0x40145000, 9636, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40145000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40148000
munmap(0x40014000, 3102)                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40014000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40149000
write(2, "test 3 nonconsecutive pages - 40"..., 49) = 49
semget(16, 0, 0)                        = -1 ENOSYS (Function not implemented)
_exit(16)                               = ?


More information about the lfs-dev mailing list