-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
eof: Contract creation fix and tests. #15595
Conversation
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
ff71ab2
to
270cece
Compare
libevmasm/Assembly.cpp
Outdated
uint8_t nUnreferenced = 0; | ||
for (uint8_t i = 0; i < static_cast<uint16_t>(m_subs.size()); ++i) | ||
for (uint8_t i = 0; i < static_cast<ContainerID>(m_subs.size()); ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i
will overflow and the loop will never stop when there are 256 sections. You need a bigger type to iterate over sections:
for (uint8_t i = 0; i < static_cast<ContainerID>(m_subs.size()); ++i) | |
for (size_t i = 0; i < m_subs.size(); ++i) |
Would be best if we could have this corner case covered with a test. Maybe one with empty subobjects to keep it compact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Shit I assumed for some reason that 0x100 == 100
👯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really makes me question whether not investing more time into tests at this stage is a wise decision. Ultimately mistakes like this should be caught by tests. We're rushing towards semantic tests, but some cases like this one definitely would not be caught by them. And these smaller PRs are the only place to consider corner cases in detail. Once it's all in, no one will have time to go back through the whole backend and figure out where extra tests are needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding tests too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reminds me also to add proper error to AsmAnalysis
covering the case when we have more then 256 subcontainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// return | ||
// stop | ||
// | ||
// sub_0: assembly { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should be removing unreferenced containers somewhere before assembling after all. It's actually a bit weird that we show them in assembly but then they're missing from the bytecode. It makes the assembly less reliable as way for users to inspect what is being generated (and for me to verify that the expectations are actually correct because the change is only in the binary :)).
Of course it's not something to address in this PR, but maybe something to think about. The problem is actually similar to removing unreferenced functions from CFG in a way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also remove the subcontainers earlier. On CFG level ideally.
270cece
to
7f7a13a
Compare
b277d4f
to
44c3096
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I'd just tweak one test (see below).
Also, the PR now does quite a bit more than just fix the IDs - it also adds a new validation and fixes the infinite loop bug. If this wasn't experimental code, each of those would get a separate changelog entry so I think at least putting them in separate commits is warranted. The commit description no longer accurately reflects what's inside.
44c3096
to
04813cb
Compare
4480387
to
52781f0
Compare
52781f0
to
6b347a1
Compare
ContainerID
usage