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

Fix an index error in ArenaVectorBase::insertAt #3486

Merged
merged 1 commit into from
Jan 13, 2021

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Jan 13, 2021

Because resize() sets usedElements to its argument, we were
accessing data[usedElements], which can be outside of allocated memory
depending the internal state, i.e., allocatedElements's value.

It is hard to come up with a test case for this because apparently the
failure condition depends on the vector's internal state.

Because `resize()` sets `usedElements` to its argument, we were
accessing `data[usedElements]`, which can be outside of allocated memory
depending the internal state, i.e., `allocatedElements`'s value.

It is hard to come up with a test case for this because apparently the
failure condition depends on the vector's internal state.
@aheejin aheejin requested a review from dcodeIO January 13, 2021 14:50
@aheejin aheejin changed the title Fix an index error in ArenaVectorBase Fix an index error in ArenaVectorBase::insertAt Jan 13, 2021
Copy link
Contributor

@dcodeIO dcodeIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. Good find!

@aheejin aheejin merged commit f882781 into WebAssembly:master Jan 13, 2021
@aheejin aheejin deleted the insert_at_fix branch January 13, 2021 16:52
kripken added a commit that referenced this pull request Jan 14, 2021
Followup to #3486, I wonder if it isn't a little more clear this way,
which avoids the confusion of usedElements being changed
while we are using it.

In general I think it's best to only use usedElements in the most
internal methods, and to call size() otherwise.
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.

None yet

2 participants