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

memory allocation bugs #731

Closed
wants to merge 2 commits into from
Closed

Conversation

g-r-a-n-t
Copy link
Member

What was wrong?

Similar to #684.

I should look over all uses of avail and alloc.

To-Do

  • OPTIONAL: Update Spec if applicable

  • Add entry to the release notes (may forgo for trivial changes)

  • Clean up commit history

@Y-Nak
Copy link
Member

Y-Nak commented Jun 3, 2022

I've been considering this and now think that it'd be better to resolve this problem in #724.
When we switch to sonatina, this problem would arise again because it'll reuse allocated memory repeatedly.
We could resolve this by always zeroing memory when a variable is declared but this will cause performance degradation.

@Y-Nak
Copy link
Member

Y-Nak commented Jun 3, 2022

But we should fix dynamic type encoding functions, where I wrongly assumed that allocated space for encoding is always zeroed. e.g., padding bytes should be explicitly zeroed here.

let func_def = function_definition! {
function [func_name.ident()]([src.ident()], [dst.ident()]) -> [enc_size.ident()] {
(let [string_len.ident()] := mload([src.expr()]))
([enc_size.ident()] := add(32, (mul([string_len.expr()], 32))))
(let data_size := add(32, [string_len.expr()]))
([yul::Statement::Expression(provider.ptr_copy(db, src.expr(), dst.expr(), literal_expression!{data_size}, false, is_dst_storage))])
([enc_size.ident()] := mul((div((add(data_size, 31)), 32)), 32))
}
};

@g-r-a-n-t
Copy link
Member Author

see #747

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

Successfully merging this pull request may close these issues.

2 participants