csmith-project / csmith

Csmith, a random generator of C programs
http://embed.cs.utah.edu/csmith/
Other
1.02k stars 146 forks source link

testcase generated by by csmith contains sanitize error(undefined-behavior): store to misaligned address and unsigned integer overflow #153

Open sendaoYan opened 1 year ago

sendaoYan commented 1 year ago

test command:

csmith -s 3290578612 > test.c
clang -w -O0 -g3 -fsanitize=undefined,unsigned-integer-overflow test.c -I /home/yansendao/tone/run/csmith/csmith-binary/include && ./a.out

result:

test.c:599:13: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'uint64_t' (aka 'unsigned long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:599:13 in 
test.c:789:13: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'uint32_t' (aka 'unsigned int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:789:13 in 
test.c:627:72: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 fe ff ff ff d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:627:72 in 
test.c:627:25: runtime error: store to misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 fe ff ff ff d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:627:25 in 
test.c:639:17: runtime error: store to misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 01 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:639:17 in 
test.c:642:278: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:642:278 in 
test.c:696:504: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:696:504 in 
test.c:716:111: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:716:111 in 
test.c:483:221: runtime error: store to misaligned address 0x00000065d8fb for type 'int16_t' (aka 'short'), which requires 2 byte alignment
0x00000065d8fb: note: pointer points here
 0f  58 01 00 ba c6 ff ff fa  ff a6 00 20 88 ce ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:483:221 in 
test.c:483:377: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:483:377 in 
/home/yansendao/tone/run/csmith/csmith-binary/include/safe_math.h:863:14: runtime error: unsigned integer overflow: 0 - 1711514803 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/yansendao/tone/run/csmith/csmith-binary/include/safe_math.h:863:14 in 
test.c:505:13: runtime error: store to misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:505:13 in 
test.c:367:13: runtime error: store to misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:367:13 in 
test.c:243:167: runtime error: store to misaligned address 0x00000065de7b for type 'int16_t' (aka 'short'), which requires 2 byte alignment
0x00000065de7b: note: pointer points here
 fa  ff 6d 83 04 df 45 ff 1f  62 10 00 00 07 00 c4 3c  63 6f 01 93 50 00 c0 16  10 00 40 f8 cf f9 bf
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:243:167 in 
test.c:243:9: runtime error: store to misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 eb 56 69 ca d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:243:9 in 
test.c:249:127: runtime error: load of misaligned address 0x00000065d90a for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:249:127 in 
test.c:249:245: runtime error: load of misaligned address 0x00000065d90a for type 'const int32_t' (aka 'const int'), which requires 4 byte alignment
0x00000065d90a: note: pointer points here
 ff 0f  05 91 00 00 00 00 d7 0a  09 00 a3 14 fe 9f cf 34  fb ff a3 ed 03 00 00 04  b6 00 00 4d 04 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:249:245 in 
test.c:249:13: runtime error: store to misaligned address 0x00000065dec5 for type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x00000065dec5: note: pointer points here
 00 00 0b 00 8d 31 37  bd a4 4e 1c 00 80 87 0d  00 f0 01 00 04 18 61 fe  ff fa 01 ce 01 18 c6 00  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:249:13 in 
checksum = AE84E1A6

test.c.zip

regehr commented 1 year ago

unsigned integer overflows are not undefined behavior in C -- this is definitely not a bug in Csmith.

the misaligned accesses are a bug, but I doubt that we're going to fix it unless @jxyang has time to take a look. we have moved on to other projects and Csmith is in maintenance mode or worse these days.