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

Econia decompilation substitutes erroneous goto statement for break #4

Open
alnoki opened this issue Mar 7, 2024 · 0 comments
Open

Comments

@alnoki
Copy link

alnoki commented Mar 7, 2024

@wrwg

Steps to reproduce

econia=0xc0deb00c405f84c85dc13442e305df75d1288100cdd82675695f6148c7ece51c
url=https://fullnode.mainnet.aptoslabs.com
aptos move download --account $econia --bytecode --package Econia --url $url
aptos move decompile --package-path Econia/bytecode_modules

Then see avl_queue.mv.move::traverse

Commentary

This produces the following

    fun traverse<T0>(arg0: &AVLqueue<T0>, arg1: u64, arg2: bool) : (u64, u64, u64) {
        let v0 = &arg0.tree_nodes;
        let (v1, v2) = if (arg2 == true) {
            (56, 42)
        } else {
            (42, 56)
        };
        let v3 = 0x1::table_with_length::borrow<u64, TreeNode>(v0, arg1).bits;
        let v4 = v3;
        let v5 = (v3 >> v1 & (16383 as u128)) as u64;
        let v6 = v5;
        if (v5 == (0 as u64)) {
            v6 = arg1;
            loop {
                let v7 = (v4 >> 70 & (16383 as u128)) as u64;
                if (v7 == (0 as u64)) {
                    break
                };
                let v8 = 0x1::table_with_length::borrow<u64, TreeNode>(v0, v7);
                let v9 = v8.bits;
                v4 = v9;
                if (((v9 >> v2 & (16383 as u128)) as u64) == v6) {
                    /* goto 13 */
                } else {
                    v6 = v7;
                };
            };
            return (0 as u64, 0 as u64, 0 as u64)
        };
        let v10;
        loop {
            let v11 = 0x1::table_with_length::borrow<u64, TreeNode>(v0, v6);
            v10 = v11;
            let v12 = (v11.bits >> v2 & (16383 as u128)) as u64;
            v6 = v12;
            if (v12 == (0 as u64)) {
                break
            };
        };
        /* label 13 */
        let v13 = v10.bits;
        ((v13 >> 94 & (4294967295 as u128)) as u64, (v13 >> 28 & (16383 as u128)) as u64, (v13 >> 14 & (16383 as u128)) as u64)
    }

Compare with https:https://github.com/econia-labs/econia/blob/3c0fb383ec4109e02277138e41ee420b03127bc2/src/move/econia/sources/avl_queue.move#L4564

There is a decompiled goto comment where there should be a break statement

@alnoki alnoki changed the title Econia decompilation produces erroneous goto statement Econia decompilation substitutes erroneous goto statement for break Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant