aptos-core
aptos-core copied to clipboard
[compiler-v2] Disassembler doesn't work with source map constructed by the compiler
The source map generation introduced in #12534 works fine with the prover but crashes with the disassembler. The problem can be reproduced by searching for the bug number in model.rs
, disassemble
function.
Does this bug appear in aptos move disassemble
? If so it is urgent.
I'm not sure if this appears in aptos move disassemble
but if we try to run move-cli tests with MOVE_COMPILER_V2=true
we hit this failure. So it's likely we'll see the same problem in Aptos.
This at least needs more investigation.
@wrwg Do you recall where/how you saw this bug?
I'm not sure if the problem I just found and fixed is the one which Wolfgang mentioned originally, as I see an error with disassembly which occurs either with the "dummy" source map
let smap = SourceMap::dummy_from_view(&view, self.env.to_ir_loc(&self.get_loc()))
.expect("source map");
or the local source map:
let smap = self.data.source_map.as_ref().expect("source map").clone();
When I run UB=1 MOVE_COMPILER_V2=true cargo test -p move-cli
I see problem with disassemblies in various tests, for example third_party/move/tools/move-cli/tests/build_tests/build_with_warnings/args.exp
which yields an error instead of a disassembly with compiler-v2:
Error: Unable to get type for local at index 0
The problem is that FunctionGenerator::temp_to_local
(in move-compiler-v2/src/file_format_generator/function_generator.rs
) is used to allocate both parameters and locals, but as a side-effect it calls self.gen.source_map.add_local_mapping(...)
, which should only be called for locals, as parameters are recorded elsewhere. Adding a flag to temp_to_local()
to change the behavior in the case where it is used to allocate parameters fixes the problem.
I have a fix I will can clean up and send out after I finish some other issues. Or you can try cherry-picking it from my work-in-progress branch https://github.com/aptos-labs/aptos-core/tree/brm-issue-11146-step3
. (Note that branch has some other problems with publishing deps in tests, which I'm still working out.)
Btw, if we could publish some more precise instructions for replicating the original issue that would be good.
@wrwg please check whether this fixes the original problem you saw.
We need to test whether aptos move disassemble
works, if so, we are good.
It looks like aptos move disassemble
works on hundreds of .mv files (built e2e-move-tests with MOVE_COMPILER_V2=true).
So I think this is fixed.
Fixed.