Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][move-compiler-v2] MOVELOC_UNAVAILABLE_ERROR related bugs raised by V2 #13687

Open
zzjas opened this issue Jun 13, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working compiler-v2-stable compiler-v2 move-smith stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@zzjas
Copy link

zzjas commented Jun 13, 2024

🐛 Bug

To reproduce

Try to compile the following code with MVC_EXP=ast-simplify=off aptos move compile --compiler-version v2 --language-version 2 or MVC_EXP=optimize=off aptos move compile --compiler-version v2 --language-version 2.

Code snippet to reproduce

module 0xCAFE::Module1 {
    struct Struct3 has drop, copy {
        var32: u16,
        var33: u32,
        var34: u8,
        var35: u32,
        var36: u32,
    }

    public fun function6(): Struct3 {
        let var44: u16 =  21859u16;
        let var45: u32 =  1399722001u32;
        Struct3 {
            var32: var44,
            var33: var45,
            var34: 154u8,
            var35: var45,
            var36: var45,
        }
    }
}

Stack trace/error message

bug: bytecode verification failed with unexpected status code `MOVELOC_UNAVAILABLE_ERROR`. This is a compiler bug, consider reporting it.
   ┌─ ~/debug_package/sources/0.move:13:9
   │  
14 │ ╭         Struct3 {
15 │ │             var32: var44,
16 │ │             var33: var45,
17 │ │             var34: 154u8,
18 │ │             var35: var45,
19 │ │             var36: var45,
20 │ │         }
   │ ╰─────────^

{
  "Error": "Move compilation failed: exiting with bytecode verification errors"
}

Expected Behavior

It should compile as it does with aptos move compile and aptos move compile --compiler-version v2 --language-version 2.

Additional context

If the last use of var45 is changed to some number literal, it will compile fine: e.g.

...
            var36: 1399722001u32,
...
@zzjas zzjas added bug Something isn't working compiler-v2 labels Jun 13, 2024
@zzjas
Copy link
Author

zzjas commented Jun 21, 2024

The fuzzer found another MOVELOC_UNAVAILABLE_ERROR case:

module 0xCAFE::Module0 {
    public fun function2<T1: drop + store> (var3: T1, var4: T1): T1 {
        if (((var3 == var3) && if (true)  { false } else { true }))  {
        } else {};
        var4
    }
}

Compiling with aptos move compile gives:

error[E06002]: use of unassigned variable
  ┌─ ~/debug_package/sources/repro.move:3:23
  │
3 │         if (((var3 == var3) && if (true)  { false } else { true }))  {
  │               ----    ^^^^ Invalid usage of previously moved variable 'var3'.
  │               │        
  │               The value of 'var3' was previously moved here.
  │               Suggestion: use 'copy var3' to avoid the move.

Compiling with aptos move compile --compiler-version v2 --language-version 2 gives:

bug: bytecode verification failed with unexpected status code `MOVELOC_UNAVAILABLE_ERROR`. This is a compiler bug, consider reporting it.
  ┌─ ~/debug_package/sources/repro.move:3:14
  │
3 │         if (((var3 == var3) && if (true)  { false } else { true }))  {
  │              ^^^^^^^^^^^^^^

@zzjas zzjas changed the title [Bug][move-compiler-v2] Copy during struct initialization causes bytecode verification to fail when ast-simplify is off [Bug][move-compiler-v2] MOVELOC_UNAVAILABLE_ERROR related bugs raised by V2 Jun 21, 2024
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label Jun 27, 2024
@wrwg wrwg self-assigned this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2-stable compiler-v2 move-smith stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants