fix: correct ArrayQueue boundaries in takeWhile and takeFromEndWhile - #301119
Conversation
|
Review the PR please João Moreno (@joaomoreno) |
|
Sangeet (@Muszic) Did you review it yourself? What's up with those monaco.d.ts changes? Please remove them. |
2624ff2 to
5429fc5
Compare
|
João Moreno (@joaomoreno) Apologies for that! The local watch task generated those diffs while I was compiling the test runner, and I mistakenly lumped them into the commit. I have removed the monaco.d.ts changes and updated the branch. The PR is now strictly scoped to the ArrayQueue logic fix and the regression tests. Thanks for catching that! |
|
Review the PR please João Moreno (@joaomoreno) |
|
Moving it to Henning Dieterichs (@hediet) |
|
Review the PR please Henning Dieterichs (@hediet) |
3 similar comments
|
Review the PR please Henning Dieterichs (@hediet) |
|
Review the PR please Henning Dieterichs (@hediet) |
|
Review the PR please Henning Dieterichs (@hediet) |
|
Henning Dieterichs (@hediet) I updated the branch and triggered a rebuild to clear out those flaky infrastructure failures (OOM and GPU crash). Whenever you have a moment, could you approve the workflows to run again? Thank you! |
|
Ulugbek Abdullaev (@ulugbekna) Henning Dieterichs (@hediet) Thank you both for the reviews and approvals! Since I am an outside contributor, the CI is currently paused. Could one of you please trigger the workflows when you get a chance so the auto-merge can finish up? Thank you! |
|
Henning Dieterichs (@hediet) Ulugbek Abdullaev (@ulugbekna) Thank you both again for the approvals! The CI is currently failing on the Linux runners, but the errors appear to be completely unrelated infrastructure/main branch issues rather than the ArrayQueue changes. Specifically: Since the core logic changes have been approved, could one of you kindly force-merge this, or trigger a re-run if those main branch issues have been patched? Thank you! |
|
Henning Dieterichs (@hediet) Ulugbek Abdullaev (@ulugbekna) Can you please trigger a re-run or force merge |
1d245ca to
c4782a0
Compare
|
João Moreno (@joaomoreno) Henning Dieterichs (@hediet) Ulugbek Abdullaev (@ulugbekna) Megan Rogge (@meganrogge) Any update guys on merging this PR |
8047af4 to
b2af2ba
Compare
|
Can you please run the workflows and merge Henning Dieterichs (@hediet) |
|
Can you please run the workflows and merge Henning Dieterichs (@hediet) Ulugbek Abdullaev (@ulugbekna) |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes a bug in ArrayQueue.takeWhile and takeFromEndWhile where the loop bounds used the underlying array's full range instead of respecting the queue's current firstIdx/lastIdx window. This caused incorrect results when both methods were used on the same queue.
Changes:
- Use
this.lastIdxas the upper bound intakeWhileinstead ofthis.items.length. - Use
this.firstIdxas the lower bound intakeFromEndWhileinstead of0. - Add a mixed-usage test covering both orderings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/base/common/arrays.ts | Constrain loop iteration to the active queue window in both take methods. |
| src/vs/base/test/common/arrays.test.ts | Adds a test verifying correct behavior when takeWhile and takeFromEndWhile are mixed. |
|
merge the PR please Henning Dieterichs (@hediet) |
This PR fixes two symmetrical boundary bugs in
ArrayQueuewheretakeWhileandtakeFromEndWhilewould ignore the internallastIdxandfirstIdxpointers. If both methods were interleaved on the same queue instance, it would lead to out-of-bounds reading and queue state corruption.Fixes:
takeWhilenow correctly checksstartIdx <= this.lastIdx(previously checked againstthis.items.length).takeFromEndWhilenow correctly checksendIdx >= this.firstIdx(previously checked>= 0).Tests:
Added regression tests to
arrays.test.tsto ensure that mixed calls totakeWhileandtakeFromEndWhilesafely respect the active boundaries of the queue. Also includes the updatedmonaco.d.tsgenerated by the watch task.