Closed shenghaoyuan closed 2 months ago
Known issue: https://github.com/solana-labs/rbpf/pull/548 https://github.com/solana-labs/solana/issues/32924
The inconsistency looks like it comes from the input side:
let a = (x as i32).wrapping_add(y as i32) as u64;
let b = (x as u32).wrapping_add(y as u32) as u64;
But it actually happens on the output side:
let c = (x as u32).wrapping_add(y as u32) as i32 as u64;
let d = (x as u32).wrapping_add(y as u32) as u32 as u64;
Hello, It looks like there are some inconsistency when Solana rbpf deals with the type-casting using
i32
andu32
. e.g.ebpf::ADD32_IMM
considersdst
andimm
asi32
firstly, then asu64
, whileebpf::OR32_IMM
considersdst
andimm
asu32
first, then asu64
Does Solana rbpf perform some specific operations on e.g. eBPF
ADD ...
? Asself.reg[dst] = (self.reg[dst] as i32).wrapping_add(insn.imm as i32) as u64
andself.reg[dst] = (self.reg[dst] as u32).wrapping_add(insn.imm as u32) as u64
may have different results.When Linux eBPF performs type-casting, it always follows a consistent way