Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug] VM validation error on inline function #6615

Open
lightmark opened this issue Feb 15, 2023 · 6 comments
Open

[Bug] VM validation error on inline function #6615

lightmark opened this issue Feb 15, 2023 · 6 comments
Assignees
Labels
bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@lightmark
Copy link
Contributor

lightmark commented Feb 15, 2023

🐛 Bug
When implement inline fun all<K, V> to SmartTable and run test_all.
The following error shows up:

2023-02-15T18:39:37.467108Z ERROR {"message":"Error: VMError { major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR, sub_status: None, message: Some("moving container with dangling references"), exec_state: Some(ExecutionState { stack_trace: [(Some(ModuleId { address: 0000000000000000000000000000000000000000000000000000000000000001, name: Identifier("smart_table") }), FunctionDefinitionIndex(7), 12), (Some(ModuleId { address: 0000000000000000000000000000000000000000000000000000000000000001, name: Identifier("smart_table") }), FunctionDefinitionIndex(19), 69)] }), location: Module(ModuleId { address: 0000000000000000000000000000000000000000000000000000000000000001, name: Identifier("table_with_length") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 13)] }\nCORE DUMP: >>>>>>>>>>>>\nCall stack:\n frame #0: 0x0000000000000000000000000000000000000000000000000000000000000001::smart_table::test_all [pc = 69]\n frame #1: 0x0000000000000000000000000000000000000000000000000000000000000001::smart_table::destroy [pc = 12]\nframe #2: 0x0000000000000000000000000000000000000000000000000000000000000001::table_with_length::remove [pc = 13]:\n0> CopyLoc(0)\n1> MutBorrowFieldGeneric(FieldInstantiationIndex(0))\n2> MoveLoc(1)\n3> CallGeneric(7)\n4> StLoc(2)\n5> CopyLoc(0)\n6> ImmBorrowFieldGeneric(FieldInstantiationIndex(1))\n7> ReadRef\n8> LdU64(1)\n9> Sub\n10> MoveLoc(0)\n11> MutBorrowFieldGeneric(FieldInstantiationIndex(1))\n12> WriteRef\n13 MoveLoc(2)\nLocals (120f35e08):\n[0] Invalid\n[1] Invalid\n[2] (container 120f37878: [(container 120f36738: [U64(13618872872554492724), U64(47), U64(47)])])\nOperand Stack:\n\n<<<<<<<<<<<<\n"}

To reproduce
git checkout smart_table_debug
cd aptos-core/aptos-move/move-examples/data_structures
aptos move test
Actually this triggers line https://github.com/move-language/move/blob/d80b5bea4cb1eef5fc456d6c26e55485a1223c86/language/move-vm/types/src/values/values_impl.rs#L1007 somehow...
@vgao1996 may have a better understanding of this.

Expected Behavior
test pass

System information
Please complete the following information:

Main Branch
rustc 1.66.1 (90743e729 2023-01-10)
OSX
Additional context
Add any other context about the problem here.

@lightmark lightmark added the bug Something isn't working label Feb 15, 2023
@wrwg wrwg moved this from 🆕 New to For Grabs in Move Language and Runtime Feb 16, 2023
@wrwg wrwg moved this from For Grabs to 🏗 In progress in Move Language and Runtime Feb 16, 2023
@wrwg
Copy link
Contributor

wrwg commented Feb 16, 2023

There might be two problems. (a) Wrong code generation from inline functions (b) wrong code not detected by the verifier

@wrwg wrwg assigned runtian-zhou and unassigned vgao1996 Feb 16, 2023
@sherry-x sherry-x changed the title [Bug] VMError: UNKNOWN_INVARIANT_VIOLATION_ERROR triggered when implementing smart_table::all inline function [Bug] inline function Feb 17, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Move Language and Runtime Feb 17, 2023
@lightmark lightmark reopened this Jun 22, 2023
@github-project-automation github-project-automation bot moved this from ✅ Done to 📋 Backlog in Move Language and Runtime Jun 22, 2023
@wrwg wrwg moved this from 📋 Backlog to For Grabs in Move Language and Runtime Jun 23, 2023
@wrwg wrwg moved this from For Grabs to 🆕 New in Move Language and Runtime Jun 23, 2023
@lbmeiyi lbmeiyi moved this from 🆕 New to For Grabs in Move Language and Runtime Jul 5, 2023
@brmataptos brmataptos self-assigned this Jul 5, 2023
@brmataptos brmataptos moved this from For Grabs to 🏗 In progress in Move Language and Runtime Jul 5, 2023
@brmataptos
Copy link
Contributor

Function inlining seems ok here. I've moved the example to tip-of-tree as branch brm-smart-table-bug, renaming to smart_table2 to avoid naming conflicts now that there is a smart_table in Aptos stdlib, with two commits on top which provide a manually-inlined version of the failing test (test_all_manual_inline) and verbose debugging of the inlining process which I've used to validate the correctness of the manual version. see branch https://github.com/aptos-labs/aptos-core/tree/brm-smart-table-bug.

I'm guessing it's a VM validator bug.

@brmataptos brmataptos changed the title [Bug] inline function [Bug] VM validation error on inline function Jul 6, 2023
@brmataptos
Copy link
Contributor

@lightmark Can you take a look at the manual version I've added in that branch mentioned above and verify it should validate?

@sausagee sausagee assigned vgao1996 and unassigned brmataptos Jul 6, 2023
@rahxephon89 rahxephon89 self-assigned this Jul 6, 2023
@rahxephon89
Copy link
Contributor

@vgao1996 @runtian-zhou This is related to the check in values_impl.rs that has not been enabled. Do you have any idea on how to proceed?

@runtian-zhou
Copy link
Contributor

I'll schedule a sync-up meeting on this!

@brmataptos
Copy link
Contributor

I'm deprioritizing this in favor of a move-compiler-v2 bug to make sure we don't generate code that triggers the VM situation.

@rahxephon89 rahxephon89 moved this from 🏗 In progress to 📋 Backlog in Move Language and Runtime Sep 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 📋 Backlog
Development

No branches or pull requests

8 participants