(CLJS) timeout timers access array elements with out-of-bounds index

Description

As a consequence of the revision made (incrementing the index used in aset), we can now see failures if you set :checked-arrays to :warn.

It appears the problematic code is the aset in the SkipList put implementation that reads

and it appears that this is simply growing the array by appending one element on the end.

You can see this if you add :checked-arrays :warn in the dev cljsbuid section of project.clj and run the tests. You will get Error: Assert failed: (< idx (alength array)) violations.

Environment

None

Activity

Show:
Mike Fikes
April 18, 2021, 5:30 PM

Fixing the issue as described revealed a few additional similar ones behind it, visible when running the tests with :checked-arrays :warn

ASYNC-237.patch includes only those changes needed to get the tests to pass.

aset}}s are converted to {{.push calls when needed and since this is in the context of a loop where the index increments by one, I think you can argue that .push is correct (in other words, there would never be a case where we would want to set an element at an index more than one beyond the last.)

Fixed

Assignee

David Nolen

Reporter

Mike Fikes

Approval

Accepted

Patch

Code and Test