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

transact_raw sometimes corrupts the stack on recursive calls #122

Closed
ureeves opened this issue Dec 16, 2022 · 0 comments · Fixed by #121
Closed

transact_raw sometimes corrupts the stack on recursive calls #122

ureeves opened this issue Dec 16, 2022 · 0 comments · Fixed by #121
Assignees
Labels
fix:bug Something isn't working mark:next Strategic issues related to next versions of Testnet and mid/long term plans team:Core Low Level Core Development Team (Rust)

Comments

@ureeves
Copy link
Member

ureeves commented Dec 16, 2022

Describe the bug
Transact raw sometimes leads to stack corruption when a module calls itself recursively. This is visible in the raw-calls-layout branch in this repository. The self_snapshot test will produce an out of bounds access to the heap, which happens due to the pointer to the raw transaction buffer being corrupted.

To Reproduce
Take a look at the raw-calls-layout branch. An MRE exists there.

Expected behaviour
Quite simply this should not happen. A recursive call should not touch the caller's stack.

Additional context
This was found in a larger effort to migrate the genesis contracts to use this library. transact_raw is used there dusk-network/rusk#757.

@ureeves ureeves added fix:bug Something isn't working team:Core Low Level Core Development Team (Rust) labels Dec 16, 2022
@ureeves ureeves changed the title transact_raw sometimes corrupts the stack when called recursively transact_raw sometimes corrupts the stack on recursive calls Dec 16, 2022
ureeves added a commit that referenced this issue Dec 16, 2022
Ensures a module is only ever instantiated once per session, by using a
map in the call stack. If an instance already exists in an instance map,
then an element is appended without creating a new instance. If an instance
does not exist in the map, a new one is created and then a new element
appended to the stack.

Resolves #122
ureeves added a commit that referenced this issue Dec 16, 2022
Ensures a module is only ever instantiated once per session, by using a
map in the call stack. If an instance already exists in an instance map,
then an element is appended without creating a new instance. If an instance
does not exist in the map, a new one is created and then a new element
appended to the stack.

Resolves #122
@ureeves ureeves added the mark:next Strategic issues related to next versions of Testnet and mid/long term plans label Dec 16, 2022
@ureeves ureeves self-assigned this Dec 16, 2022
ureeves added a commit that referenced this issue Dec 16, 2022
Ensures a module is only ever instantiated once per session, by using a
map in the call stack. If an instance already exists in an instance map,
then an element is appended without creating a new instance. If an instance
does not exist in the map, a new one is created and then a new element
appended to the stack.

Resolves #122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:bug Something isn't working mark:next Strategic issues related to next versions of Testnet and mid/long term plans team:Core Low Level Core Development Team (Rust)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant