ltp测试套件-pthread_barrier_wait_6-1分析记录

测试用例地址:

https://github.com/linux-test-project/ltp/commit/b54a54e5881a0f9438ce4a862dee724130a9874f#diff-61ca0ddb356007047210a92fb128896c
(1)失败打印:
POSIX:conformance/interfaces/pthread_barrier_wait/pthread_barrier_wait_6-1: execution: SIGNALED:
(2)问题原因与解决:(Remove pthread_barrier_wait_6-1 because it is unreliable,应移除用例)
原因是未初始化的barrier变量,陷入系统调用会返回-ESYS,glibc库查看返回值如果是-ESYS,则报错误。

分析记录:

/ltp/conformance/interfaces/pthread_barrier_wait # chmp^C
/ltp/conformance/interfaces/pthread_barrier_wait # chmod 777 strace.1043le 
/ltp/conformance/interfaces/pthread_barrier_wait # ./strace.1043le pthread_barri
er_wait61 
./strace.1043le: Can't stat 'pthread_barrier_wait61': No such file or directory
/ltp/conformance/interfaces/pthread_barrier_wait # ./strace.1043le ./pthread_bar
rier_wait61 
execve("./pthread_barrier_wait61", ["./pthread_barrier_wait61"], [/* 12 vars */]) = 0
brk(NULL)                               = 0x28848000
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/tls/aarch64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib/tls/aarch64", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/tls/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib/tls", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/aarch64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib/aarch64", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib", {st_mode=S_IFDIR|0755, st_size=0, ...}, 0) = 0
openat(AT_FDCWD, "/lib/tls/aarch64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/lib/tls/aarch64", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/tls/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/lib/tls", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/aarch64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/lib/aarch64", 0xffffe38e0200, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\320[\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=135544, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff99fc9000
mmap(NULL, 177048, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff99f76000
mprotect(0xffff99f8d000, 61440, PROT_NONE) = 0
mmap(0xffff99f9c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0xffff99f9c000
mmap(0xffff99f9e000, 13208, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff99f9e000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0x\364\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1541648, ...}) = 0
mmap(NULL, 1340024, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff99e2e000
mprotect(0xffff99f5d000, 61440, PROT_NONE) = 0
mmap(0xffff99f6c000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12e000) = 0xffff99f6c000
mmap(0xffff99f72000, 12920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff99f72000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff99fc7000
mprotect(0xffff99f6c000, 16384, PROT_READ) = 0
mprotect(0xffff99f9c000, 4096, PROT_READ) = 0
mprotect(0xffff99fcd000, 4096, PROT_READ) = 0
set_tid_address(0xffff99fca1c0)         = 1440
set_robust_list(0xffff99fca1d0, 24)     = 0
rt_sigaction(SIGRTMIN, {0xffff99f7b5e0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xffff99f7b6d8, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
rt_sigaction(SIGALRM, {0x400870, ~[RTMIN RT_1], 0}, NULL, 8) = 0
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, {it_interval={0, 0}, it_value={0, 0}}) = 0
futex(0xffffe38e0f40, 0xff7f /* FUTEX_??? */, 3817738081, 0, e38e0f61, 0) = -1 ENOSYS (Function not implemented)
openat(AT_FDCWD, "/dev/tty", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3
writev(3, [{iov_base="The futex facility returned an u"..., iov_len=53}], 1The futex facility returned an unexpected error code.) = 53
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff99fc6000
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 1440
gettid()                                = 1440
tgkill(1440, 1440, SIGABRT)             = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=1440, si_uid=0} ---
+++ killed by SIGABRT +++
Aborted
/ltp/conformance/interfaces/pthread_barrier_wait # 


futex返回ENOSYS,tsp的gcc620工具链中做了判断:
58 static __always_inline int
 59 futex_wait (unsigned int *futex_word, unsigned int expected, int private)
 60 {
 61   int err = lll_futex_timed_wait (futex_word, expected, NULL, private);
 62   switch (err)
 63     {
 64     case 0:
 65     case -EAGAIN:
 66     case -EINTR:
 67       return -err;
 68
 69     case -ETIMEDOUT: /* Cannot have happened as we provided no timeout.  */
 70     case -EFAULT: /* Must have been caused by a glibc or application bug.  */
 71     case -EINVAL: /* Either due to wrong alignment or due to the timeout not
 72                      being normalized.  Must have been caused by a glibc or
 73                      application bug.  */
 74     case -ENOSYS: /* Must have been caused by a glibc bug.  */
 75     /* No other errors are documented at this time.  */
 76     default:
 77       futex_fatal_error ();
 78     }
 79 }

-bash-4.1$ grep futex_fatal_error -nr .
./sysdeps/nacl/futex-internal.h:82:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:110:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:135:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:164:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:190:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:220:      futex_fatal_error ();
./sysdeps/nacl/futex-internal.h:244:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:77:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:105:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:130:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:159:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:189:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:223:      futex_fatal_error ();
./sysdeps/unix/sysv/linux/futex-internal.h:247:      futex_fatal_error ();
./sysdeps/nptl/futex-internal.h:198:futex_fatal_error (void)

196    concrete implementations of the futex interface.  */
197 static __always_inline __attribute__ ((__noreturn__)) void
198 futex_fatal_error (void)
199 {
200   __libc_fatal ("The futex facility returned an unexpected error code.");
201 }
202
203 #endif  /* futex-internal.h */

## 高版本的ltp套件已经删除了这个用例
https://github.com/linux-test-project/ltp/commit/b54a54e5881a0f9438ce4a862dee724130a9874f#diff-61ca0ddb356007047210a92fb128896c

Remove pthread_barrier_wait_6-1 because it is unreliable
The test is trying assert that an uninitialised argument is handled gracefully
however the behavior of the interface is undefined when the argument has not
been initialised. This test suite is supposed to verify that any given
implementation conforms to the POSIX specification which by definition does
not include undefined behavior.

The test is currently failing on Linux with glibc because the process is
aborting for some reason other than a seg fault.

Due to security concerns, in some cases it is reasonable to assert that some
forms of behavior, such as a NULL pointer dereference, are not acceptable even
if the specification allows it. However, in order for the test to run reliably
across all implementations, we need to be able to handle any other behavior an
implementation is likely to choose. In this case the type of the argument is
opaque and so we can't make any reasonable assumptions about how it will be
handled. So then we have to handle all possible behavior and detect the
scenarios we consider unacceptable.

We feel this is too much complication for a test which is testing something
slightly outside of the test suites purpose.

Signed-off-by: Richard Palethorpe <[email protected]>
Acked-by: Cyril Hrubis <[email protected]>
Acked-by: Jan Stancek <[email protected]>

猜你喜欢

转载自blog.csdn.net/y33988979/article/details/82256735
今日推荐