data61 / MP-SPDZ

Versatile framework for multi-party computation
Other
942 stars 280 forks source link

The VM crashed when the asm_open was added to the bc file #1486

Closed HopeDevote closed 1 month ago

HopeDevote commented 2 months ago

Hello, sorry to bother you

When I legally added the asm_open instruction(line 3:vasm_open 7, 3, True, c4(7), s25(7) # 1 ) to the instruction set of the bc file

# test_array_muls-0--0
ldsi s0, 3 # 0
vasm_open 7, 3, True, c4(7), s25(7) # 1
stms s0, 8192 # 2
ldsi s1, 2 # 3
stms s1, 8195 # 4
ldsi s2, 4 # 5
stms s2, 8193 # 6
ldsi s3, 3 # 7
stms s3, 8196 # 8
ldsi s4, 5 # 9
stms s4, 8194 # 10
ldsi s5, 4 # 11
stms s5, 8197 # 12
vldms 3, s6(3), 8192 # 13
vldms 3, s12(3), 8195 # 14
muls 4, 3, s15(3), s12(3), s6(3) # 15
ldms s18, 8192 # 16
ldms s19, 8193 # 17
ldms s20, 8194 # 18
ldms s22, 8195 # 19
ldms s23, 8196 # 20
ldms s24, 8197 # 21
dotprods 8, 8, s21, s18, s22, s19, s23, s20, s24 # 22
vasm_open 3, 3, True, c0(3), s15(3) # 23
vprint_reg_plain 3, c0(3) # 24
print_char 10 # 25
asm_open 3, True, c3, s21 # 26
print_reg_plain c3 # 27
print_char 10 # 28

run ./emulate.x test_array_muls the VM crashed Fatal error: vector::_M_range_check: __n (which is 16) >= this->size() (which is 16)

Is this a bug or expected behavior?

Thanks!

mkskeller commented 2 months ago

The virtual machine only considers registers that are written to when calculating the register requirements. It seems you have added registers (s25...) that are only written to but never read from. I would argue this contradicts the idea of the bytecode.