This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

times02 test in LTP (Testcase to test that times() sets errno correctly) fails with glibc-2.8


Hi;

While playing with latest LTP release (March 2008) i realized times02 test in LTP (Testcase to test that times() sets errno correctly) fails like following with glibc-2.8

buildhouse ltp-full-20080331 # ./testcases/bin/times02
times02     1  FAIL  :  times(2) failed to FAIL

Following code snippet from this test case;

#include <stdio.h>
#include <errno.h>
#include <sys/times.h>

int main(int argc, char **argv)
{
	if (times((void *)-1)) {
		if (errno != EFAULT) {
			printf("Expected EFAULT, got %d\n", errno);
		}
		else {
			printf("Received EFAULT as expected\n");
		}
	} else {
		printf("failed to fail\n");
	}
}

PASS with glibc-2.3.6 and gcc-3.4.6 system

caglar@zangetsu ~ $ ./test
Received EFAULT as expected

but FAILS on glibc-2.8 and gcc-4.3.0 system

buildhouse ~ # ./test
Expected EFAULT, got 0

In order to eliminate compiler regressions i also test the one compiled with gcc-3.4.6 on glibc-2.8 and it also fails with same.

buildhouse ~ # ./test_old_toolchain_compiled
Expected EFAULT, got 0

"strace -ttt -TTT -o trace.log -f ./test" shows "times" syscall returns EFAULT as expected

6156  1208112749.712442 execve("./test", ["./test"], [/* 39 vars */]) = 0 <0.000202>
6156  1208112749.713227 brk(0)          = 0x9e9e000 <0.000015>
6156  1208112749.713332 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) <0.000016>
6156  1208112749.713454 open("/etc/ld.so.cache", O_RDONLY) = 3 <0.000017>
6156  1208112749.713532 fstat64(3, {st_mode=S_IFREG|0644, st_size=88351, ...}) = 0 <0.000015>
6156  1208112749.713658 mmap2(NULL, 88351, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f78000 <0.000016>
6156  1208112749.713723 close(3)        = 0 <0.000015>
6156  1208112749.713803 open("/lib/libc.so.6", O_RDONLY) = 3 <0.000018>
6156  1208112749.713877 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`g\1\0004\0\0\0"..., 512) = 512 <0.000015>
6156  1208112749.713982 fstat64(3, {st_mode=S_IFREG|0755, st_size=1478952, ...}) = 0 <0.000015>
6156  1208112749.714096 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f77000 <0.000015>
6156  1208112749.714172 mmap2(NULL, 1451600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e14000 <0.000016>
6156  1208112749.714236 mmap2(0xb7f71000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15d) = 0xb7f71000 <0.000022>
6156  1208112749.714314 mmap2(0xb7f74000, 9808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f74000 <0.000017>
6156  1208112749.714386 close(3)        = 0 <0.000015>
6156  1208112749.714465 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e13000 <0.000015>
6156  1208112749.714529 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e136c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 <0.000015>
6156  1208112749.714703 mprotect(0xb7f71000, 8192, PROT_READ) = 0 <0.000017>
6156  1208112749.714766 mprotect(0x8049000, 4096, PROT_READ) = 0 <0.000016>
6156  1208112749.714829 mprotect(0xb7fac000, 4096, PROT_READ) = 0 <0.000015>
6156  1208112749.714897 munmap(0xb7f78000, 88351) = 0 <0.000026>
6156  1208112749.714994 times(0xffffffff) = -1 EFAULT (Bad address) <0.000024>
6156  1208112749.715097 fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 <0.000021>
6156  1208112749.715223 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f8d000 <0.000022>
6156  1208112749.715319 write(1, "Expected EFAULT, got 0\n", 23) = 23 <0.000074>
6156  1208112749.715463 exit_group(23)  = ?

Any hints will be appreciated.

Cheers
-- 
S.ÃaÄlar Onur <caglar@pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]