Closed regehr closed 7 months ago
regehr@ohm:~/alive2-regehr/build$ cat src.ll
; ModuleID = 'M2'
source_filename = "M2"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-linux-gnu"
define ptr @test_array2(ptr %0) {
%2 = getelementptr inbounds i32, ptr %0, i64 4
ret ptr %2
}
regehr@ohm:~/alive2-regehr/build$ cat tgt.ll
; ModuleID = 'M2'
source_filename = "M2"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
define ptr @test_array2(ptr %0) local_unnamed_addr #0 {
arm_tv_entry:
%1 = ptrtoint ptr %0 to i64
%a2_1 = add i64 %1, 16
%2 = inttoptr i64 %a2_1 to ptr
ret ptr %2
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
regehr@ohm:~/alive2-regehr/build$ ./alive-tv src.ll tgt.ll --tgt-is-asm
----------------------------------------
define ptr @test_array2(ptr %#0) {
#1:
%#2 = gep inbounds ptr %#0, 4 x i64 4
ret ptr %#2
}
=>
define ptr @test_array2(ptr %#0) nofree willreturn asm memory(none) {
arm_tv_entry:
%#1 = ptrtoint ptr %#0 to i64
%a2_1 = add i64 %#1, 16
%#2 = int2ptr i64 %a2_1 to ptr
ret ptr %#2
}
Transformation seems to be correct!
Summary:
1 correct transformations
0 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
regehr@ohm:~/alive2-regehr/build$ ./alive-tv src.ll tgt.ll --tgt-is-asm --disable-undef-input
----------------------------------------
define ptr @test_array2(ptr %#0) {
#1:
%#2 = gep inbounds ptr %#0, 4 x i64 4
ret ptr %#2
}
=>
define ptr @test_array2(ptr %#0) nofree willreturn asm memory(none) {
arm_tv_entry:
%#1 = ptrtoint ptr %#0 to i64
%a2_1 = add i64 %#1, 16
%#2 = int2ptr i64 %a2_1 to ptr
ret ptr %#2
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
ptr %#0 = pointer(non-local, block_id=1, offset=0, attrs=1)
Source:
ptr %#2 = pointer(non-local, block_id=1, offset=16, attrs=1)
SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: 0
Block 1 > size: 16 align: 1 alloc type: 0 alive: true address: 14
Target:
i64 %#1 = #x000000000000000e (14)
i64 %a2_1 = #x000000000000001e (30)
ptr %#2 = pointer(non-local, block_id=1, offset=16)
Source value: pointer(non-local, block_id=1, offset=16, attrs=1)
Target value: pointer(non-local, block_id=1, offset=16)
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
regehr@ohm:~/alive2-regehr/build$
still running into this issue.
I can stop using --disable-undef-input
but I don't want undefs on the src side either, so I would like to use that flag.
I'm also running into issues where something validates on one of my machines and gives a value mismatch on another -- that should never happen, right?
Yeah, that's bad. You may have a bad Z3 is one of the machines. Z3 was a bit broken for a couple of weeks; you may have caught it. I can't reproduce the error you pasted above on my computer.
oh no!!! this is my main compute machine and I rebuilt Z3 there last night just before sending you this :(
I ran these on both machines with --se-verbose --smt-log
and the Z3 queries are different, here's the difff
Johns-MacBook-Pro:build regehr$ diff -cbw out.txt out-ohm.txt
*** out.txt Tue Nov 21 09:17:59 2023
--- out-ohm.txt Tue Nov 21 09:18:41 2023
***************
*** 19,27 ****
(bvule ((_ extract 63 0) |%#0|)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1 ((_ extract 63 63) |%#0|)))
(bvule (bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
- (bvsle ((_ extract 63 0) |%#0|) #x7fffffffffffffef)
(not (= #b1
((_ extract 63 63)
(bvadd ((_ extract 63 0) |%#0|) #x0000000000000010))))) / UB=(= #b0 |isundef_%#0|)
--- 19,27 ----
(bvule ((_ extract 63 0) |%#0|)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1 ((_ extract 63 63) |%#0|)))
+ (bvsle ((_ extract 63 0) |%#0|) #x7fffffffffffffef)
(bvule (bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1
((_ extract 63 63)
(bvadd ((_ extract 63 0) |%#0|) #x0000000000000010))))) / UB=(= #b0 |isundef_%#0|)
***************
*** 34,42 ****
(bvule ((_ extract 63 0) |%#0|)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1 ((_ extract 63 63) |%#0|)))
(bvule (bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
- (bvsle ((_ extract 63 0) |%#0|) #x7fffffffffffffef)
(not (= #b1
((_ extract 63 63)
(bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)))))
--- 34,42 ----
(bvule ((_ extract 63 0) |%#0|)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1 ((_ extract 63 63) |%#0|)))
+ (bvsle ((_ extract 63 0) |%#0|) #x7fffffffffffffef)
(bvule (bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)
(concat #b0 (blk_size ((_ extract 64 64) |%#0|))))
(not (= #b1
((_ extract 63 63)
(bvadd ((_ extract 63 0) |%#0|) #x0000000000000010)))))
***************
*** 111,120 ****
((_ extract 64 64) |%#0|): non-local: 11
! Transformation seems to be correct!
Summary:
! 1 correct transformations
! 0 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
--- 111,141 ----
((_ extract 64 64) |%#0|): non-local: 11
! Transformation doesn't verify!
+ ERROR: Value mismatch
+
+ Example:
+ ptr %#0 = pointer(non-local, block_id=1, offset=0, attrs=1)
+
+ Source:
+ ptr %#2 = pointer(non-local, block_id=1, offset=16, attrs=1)
+
+ SOURCE MEMORY STATE
+ ===================
+ NON-LOCAL BLOCKS:
+ Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: 0
+ Block 1 > size: 16 align: 1 alloc type: 0 alive: true address: 14
+
+ Target:
+ i64 %#1 = #x000000000000000e (14)
+ i64 %a2_1 = #x000000000000001e (30)
+ ptr %#2 = pointer(non-local, block_id=1, offset=16)
+ Source value: pointer(non-local, block_id=1, offset=16, attrs=1)
+ Target value: pointer(non-local, block_id=1, offset=16)
+
Summary:
! 0 correct transformations
! 1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
Johns-MacBook-Pro:build regehr$
the execution of alive-tv that signals a value mismatch is clean as far as valgrind can tell. I can't check the other one since that one is running on my Mac.
I recompiled both Z3 and Alive2 with Clang instead of GCC and I still see this value mismatch. but the counterexample is different now. argh!!!! something is really broken here.
worse still, when I build Z3 and Alive2 with -fsanitize=address,undefined
the problem goes away but no errors are signaled.
this behavior is recent, I'm afraid something has gone badly wrong in Z3 lately
anyhow, although I'd like to help debug this, I don't have a mechanism for doing that, I've backed off to an older Z3 and will just use that for a while
ok this one really made me tear my hair out. here's a src and tgt where Alive validates refinement
I'll leave out the output. it also validates when either poison or undef is disabled. but when I disable both I get this value mismatch with a nonsensical CEX.