Daohub-io/cap9

Failure of code_copy

JakeOShannessy opened this issue · 1 comments

There is a strange error occurring when passing the full code data from the kernel (that is using EXTCODECOPY) to a client. I'm not sure what it causing it, but reallocating the vector in some way seems to fix it.

fn code_copy(&mut self, to: Address) -> pwasm_std::Vec<u8> {
let mut code = super::extcodecopy(&to);
// TODO: FIXME: This is an awful hack. Without these two resize
// lines (which have no net effect) we hit an Unreachable trap in
// the WASM code. Jake's hypothesis is that these two lines trigger
// a reallocation of some kind (of the vector) that side-steps
// whatever issue is occuring.
code.resize(code.len()-1,0);
code.resize(code.len()+1,0);
code
}

This is currently working fine with this hack disabled. Given we can't reproduce it anymore we may just have to close it. It may have been fixed with some other changes.