[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] possible 'undefined behavior'



Hi John.
 
Thanks for your answer.
 
zig is not the issue (zig includes code from clang and llvm)
 
The undefined behavior is in the code generated by csmith and also visible, when compiling with clang.
 
ub-test with clang for seed 26:
------------------------------------------
:/run/user/1000/csmith$ DEBUG=1 CC="clang" CFLAGS="-fsanitize=undefined"  csmith.tcc.sh 26
# appname:     csmith.tcc
# shortname:   csmith
# toolchain:   tcc
# toolflags:   
# with csmith: csmith
# using csmith binary:      csmith
# using csmith seed range:  26 to 26
# using working directory:  /run/user/1000/csmith
# using reference compiler: tcc
# using reference flags:    
# using testing compiler:   clang
# using testing flags:      -fsanitize=undefined
# csmith --float --seed 26 --output /run/user/1000/csmith/00026.c
# REF  compile: tcc -std=c99 -O0 -g -lm -w -I/usr/include/csmith /run/user/1000/csmith/00026.c -o /run/user/1000/csmith/00026_ref
# TEST compile: clang -std=c99 -O0 -g -lm -w -I/usr/include/csmith -fsanitize=undefined /run/user/1000/csmith/00026.c -o /run/user/1000/csmith/00026_tst
# run: /run/user/1000/csmith/00026_ref >/run/user/1000/csmith/00026_ref.txt
# res: checksum = 2B38352E
# run: /run/user/1000/csmith/00026_tst >/run/user/1000/csmith/00026_tst.txt
/run/user/1000/csmith/00026.c:331:9: runtime error: store to misaligned address 0x5585186a7c32 for type 'float', which requires 4 byte alignment
0x5585186a7c32: note: pointer points here
 00 8c  03 00 dc f9 e7 19 b1 7d  04 00 90 03 54 0d 00 00  a0 af b4 a2 00 00 00 00  00 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /run/user/1000/csmith/00026.c:331:9 in
# res: checksum = 2B38352E
 
ok     #     /run/user/1000/csmith/00026.c
# 1 test succeeded
# 0 tests failed
# All OK
1..1
 
-----------------------
 
ub-test with clang for seed 28:
00028.c:575:35: runtime error: 7.85979e+11 is outside the range of representable values of type 'int'
 
ub-test with clang for seed 48:
00048.c:382:493: runtime error: load of misaligned address 0x55a22b4eb9e1 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment
00048.c:382:541: runtime error: load of misaligned address 0x55a22b4eb9e1 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment
00048.c:382:553: runtime error: load of misaligned address 0x55a22b4eb9e1 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment
 
ub-test with clang for seed 55:
00055.c:1862:34: runtime error: -1.40121e+28 is outside the range of representable values of type 'int'
00055.c:914:294: runtime error: load of misaligned address 0x564195539694 for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment
 
 
ub-test with clang for seed 60:
00060.c:751:51: runtime error: store to misaligned address 0x55c573444c2a for type 'float', which requires 4 byte alignment
00060.c:581:476: runtime error: store to misaligned address 0x55c573444c2a for type 'float', which requires 4 byte alignment
00060.c:581:216: runtime error: store to misaligned address 0x55c5734457ca for type 'float', which requires 4 byte alignment
 
-----------------------
 
More tomorrow.
 
(oh, in addition to the runtime error from the clang compiled testfile, the correct checksum is printed,
and my script thinks, all is ok.)
 
 
--
Bye bye ... Detlef
 
 
Gesendet: Freitag, 27. Januar 2023 um 00:05 Uhr
Von: "John Regehr" <regehr@cs.utah.edu>
An: csmith-dev@flux.utah.edu
Betreff: Re: [csmith-dev] possible 'undefined behavior'

Hi,

I can pretty much guarantee that none of us is going to look into Zig, sorry.

John

 

On 1/26/23 9:34 PM, Detlef Riekenberg wrote:

When using my csmith.sh script with 'zig cc'
many programs crashed with default settings,
but they work, when using '-fno-sanitize=undefined'

I did not invesigate more in this behavior,
but 'clang' with '-fsanitize=undefined'
should produce the same failures.

example seeds between 0 and 99 : 18, 26, 28, 48, 55, 60


--
bye bye ... Detlef