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][Compiler-v2] STLOC_UNSAFE_TO_DESTROY_ERROR #13952

Closed
zzjas opened this issue Jul 9, 2024 · 3 comments
Closed

[Bug][Compiler-v2] STLOC_UNSAFE_TO_DESTROY_ERROR #13952

zzjas opened this issue Jul 9, 2024 · 3 comments
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 Jul 9, 2024

🐛 Bug

Compiling the following code with V2:

module 0xCAFE::Module0 {
    struct Struct0 has drop, copy {
        x: bool,
    }

    public fun function5(var21: bool, var23: bool) {
        let var67 =  (&(var21) != &((var21 || var23)));
        Struct0 {
            x: var21
        };
    }
}

will raise:

bug: bytecode verification failed with unexpected status code `STLOC_UNSAFE_TO_DESTROY_ERROR`. This is a compiler bug, consider reporting it.
  ┌─ ~/debug_package/sources/repro.move:7:36
  │
7 │         let var67 =  (&(var21) != &((var21 || var23)));
  │                                    ^^^^^^^^^^^^^^^^^^

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

It can be compiled successfully with V1.

Additional context

If we add inline for function5, it will compile fine:

module 0xCAFE::Module0 {
    struct Struct0 has drop, copy {
        x: bool,
    }

    public inline fun function5(var21: bool, var23: bool) {
        let var67 =  (&(var21) != &((var21 || var23)));
        Struct0 {
            x: var21
        };
    }
}

However, if we add a caller like:

public fun caller(a: bool, b: bool) {
       function5(a, b);
}

It will give the same error.


If the use of var21 is removed, i.e.:

module 0xCAFE::Module0 {
    public fun function5(var21: bool, var23: bool) {
        let var67 =  (&(var21) != &((var21 || var23)));
    }
}

Compiling it will only raise a known issue:

error: reference safety check failed on bytecode level. This is a known issue, to be fixed later, resulting from differences between safety rules of the v1 and v2 compiler. Try to rewrite your code to workaround this problem.
  ┌─ ~/debug_package/sources/repro.move:3:36
  │
3 │         let var67 =  (&(var21) != &((var21 || var23)));
  │                                    ^^^^^^^^^^^^^^^^^^

{
  "Error": "Move compilation failed: exiting with bytecode verification errors"
}
@zzjas zzjas added bug Something isn't working compiler-v2 move-smith labels Jul 9, 2024
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label Jul 10, 2024
@wrwg wrwg self-assigned this Jul 17, 2024
@wrwg
Copy link
Contributor

wrwg commented Aug 10, 2024

Can't reproduce this at head.

@wrwg
Copy link
Contributor

wrwg commented Aug 10, 2024

In fact it is reproducible but only if optimizations is off. This might be only the case since peephole opts have landed (@vineethk ). I'll add a test case for further investigation.

@wrwg
Copy link
Contributor

wrwg commented Aug 19, 2024

Fixed by #14310

@wrwg wrwg closed this as completed Aug 19, 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: Done
Development

No branches or pull requests

4 participants