ivmai/libatomic_ops

Invalid instruction in test_stack on E2K-v5 in protected mode

ivmai opened this issue · 5 comments

Source: 7279f81 (master)
Host: Linux/e2k-v5
Linux kernel: 5.4.0-6.9-e8c2
Compiler: lcc:1.26.22:Jan-10-2024:e2k-v5-linux (gcc (GCC) 9.3.0 compatible)
How to reproduce: ./configure --enable-assertions && make -j check CFLAGS_EXTRA="-O0 -g -m128" && tests/test_stack
Occurrence: ~1/15 (higher occurrence if compiled with -O3)

Related: #61 #59

Stacktrace (if compiled with -O3): // obtained by ulimit -c unlimited; while ./tests/test_stack; do :; done; gdb tests/test_stack core

#0  0x0000000050179ef8 in AO_stack_push_explicit_aux_release ()
#1  0x000000005017aaa0 in AO_stack_push_release ()
#2  0x00000000501772a0 in run_one_test ()
#3  0x0000000050203530 in start_thread () from /lib128/libpthread.so.0

gdb reports: Program terminated with signal SIGILL, Illegal instruction.

gdb show exact line of SIGILL, if compiled with -O0 -g:

if (AO_EXPECT_FALSE(entry1 == x_bits || entry2 == x_bits))

#0  0x00000000501ab038 in AO_stack_push_explicit_aux_release (list=0x501b0180 <the_list>, x=0x50a16e80,
    a=0x501b0190 <the_list+16>) at atomic_ops_stack.c:158
158             if (AO_EXPECT_FALSE(entry1 == x_bits || entry2 == x_bits))

How to reproduce ("quick how-to"):
git clone https://github.com/ivmai/libatomic_ops.git && cd libatomic_ops && git checkout 7279f8153 && gcc -m128 -O0 -g -I src -o test_stack tests/test_stack.c src/*.c -lpthread && ulimit -c unlimited && while ./test_stack; do :; done && gdb test_stack core

As of commit cc9bc49, the issue is still reproduced.

Fixed inside kernel. No longer reproduced since Linux kernel 5.4.0-6.19.
Thanks to e2k community for verifying the bug is fixed!