iree icon indicating copy to clipboard operation
iree copied to clipboard

Remove the accumulator-aliasing workaround now that #16168 is fixed

Open bjacob opened this issue 3 weeks ago • 2 comments

Now that #16168 is fixed by #22739, we should be able to drop this work-around.

Problem: at the moment this runs into this new issue flagged by UBSan (to reproduce, compile with -DIREE_ENABLE_UBSAN=ON, ninja iree-test-deps and run the ctest command pasted below), seen on every single CPU matmul test, e.g.:

$ ctest -R iree/tests/e2e/matmul/e2e_matmul_cpu_dt_i8_i32_llvm-cpu_local-task_generic --output-on-failure
Test project /tmp/xx/iree-build
    Start 1355: iree/tests/e2e/matmul/e2e_matmul_cpu_dt_i8_i32_llvm-cpu_local-task_generic
1/1 Test #1355: iree/tests/e2e/matmul/e2e_matmul_cpu_dt_i8_i32_llvm-cpu_local-task_generic ...***Failed    0.11 sec
--- TEST[matmul_accumulate_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32_1_1_1_acc_0] ---
Matmul shape (MxKxN): 1x1x1
/tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:399:18: runtime error: member access within misaligned address 0x7ffdbaf4719c for type 'iree_vm_ref_t', which requires 8 byte alignment
0x7ffdbaf4719c: note: pointer points here
  00 00 00 00 60 c2 c3 aa  f8 55 00 00 e8 c8 1c a8  f8 55 00 00 b0 c3 c3 aa  f8 55 00 00 e8 c8 1c a8
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:399:18 
/tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:399:18: runtime error: load of misaligned address 0x7ffdbaf471a4 for type 'iree_vm_ref_type_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7ffdbaf471a4: note: pointer points here
  f8 55 00 00 e8 c8 1c a8  f8 55 00 00 b0 c3 c3 aa  f8 55 00 00 e8 c8 1c a8  f8 55 00 00 00 c5 c3 aa
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:399:18 
/tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:400:64: runtime error: member access within misaligned address 0x7ffdbaf4719c for type 'iree_vm_ref_t', which requires 8 byte alignment
0x7ffdbaf4719c: note: pointer points here
  00 00 00 00 60 c2 c3 aa  f8 55 00 00 e8 c8 1c a8  f8 55 00 00 b0 c3 c3 aa  f8 55 00 00 e8 c8 1c a8
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:400:64 
/tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:400:64: runtime error: load of misaligned address 0x7ffdbaf4719c for type 'void *', which requires 8 byte alignment
0x7ffdbaf4719c: note: pointer points here
  00 00 00 00 60 c2 c3 aa  f8 55 00 00 e8 c8 1c a8  f8 55 00 00 b0 c3 c3 aa  f8 55 00 00 e8 c8 1c a8
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/xx/iree/runtime/src/iree/vm/native_module_packing.h:400:64 
--- TEST[matmul_accumulate_1x1xi8_times_1x1xi8_into_1x1xi32_1_1_1_acc_1] ---
Matmul shape (MxKxN): 1x1x1


error: the actual and expected result matrices disagree at row 0, column 0.

actual value: 2
expected value: -2

left-hand side (rows 0..0 out of 0..0, columns 0..0 out of 0..0)
2   

right-hand side (rows 0..0 out of 0..0, columns 0..0 out of 0..0)
-2   

input accumulator (rows 0..0 out of 0..0, columns 0..0 out of 0..0)
2   

expected result (rows 0..0 out of 0..0, columns 0..0 out of 0..0)
-2🦄 

actual result (rows 0..0 out of 0..0, columns 0..0 out of 0..0)
 2🎃 

bjacob avatar Dec 05 '25 17:12 bjacob

Interesting - want to take a look or should I? (I thought jakub fixed a lot of that, so maybe something got missed or it's a different issue, would be good to know where that iree_vm_ref_t lives (stack or heap, in struct or array, etc).

benvanik avatar Dec 05 '25 17:12 benvanik

Oh I see it's a transparent issue in the source code - I had wrongly assumed that it would be something mysterious that I couldn't investigate on my own.

bjacob avatar Dec 05 '25 17:12 bjacob