Off by one bug near 32^2 elements, and probably also 32^3 etc

Description

(require '[clojure.core.rrb-vector :as fv]
'[clojure.core.rrb-vector.debug :as dv])

(def v1025 (into (fv/vector) (range 1025)))

(def v1024t (persistent! (pop! (transient v1025))))
;; This shows v1024t with nothing in it but a tail. Not correct.
(dv/dbg-vec v1024t)

;; Attempting to evaluate the expression below causes a
;; NullPointerException
(= v1024t (range 1024))

;; It is not clear to me why this does not have a similar failure, but
;; I am pretty sure there is a similar bug waiting to happen in the
;; persistent version of popTail, too.
(def v1024 (pop v1025))
(dv/dbg-vec v1024)
(= v1024 (range 1024))

Environment

None

Activity

Show:
Andy Fingerhut
August 7, 2019, 2:13 AM

With latest master version of code plus the new test case in patch crrbv-22-test-case-v1.patch, the new test case fails. With that plus the patch crrbv-22-fix-v1.patch, the new test case passes, as well as all existing ones.

Andy Fingerhut
August 7, 2019, 2:04 PM

Patch crrbv-22-cljs-fix-v1.patch is the same test cases and a similar fix for the ClojureScript code.

Andy Fingerhut
September 18, 2019, 12:29 AM

This commit:

adds both clj and cljs test cases that fail without the fix, and fixes for both clj and cljs versions of the code, nearly identical to the patches attached to this ticket.

I will close this issue as resolved if build.clojure.org confirms everything passes.

Andy Fingerhut
September 18, 2019, 1:28 AM

New tests passing with the fixes on build.clojure.org. Closing as resolved.

Assignee

Andy Fingerhut

Reporter

Andy Fingerhut

Labels

None

Approval

None

Patch

None

Priority

Major
Configure