Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Fix panic in Or/Xor when the other bitmap is empty - #58

Open
bardrop wants to merge 1 commit into
kelindar:mainfrom
bardrop-oss:fix-or-xor-empty-other
Open

bardrop wants to merge 1 commit into
kelindar:mainfrom
bardrop-oss:fix-or-xor-empty-other

Conversation

@bardrop

@bardrop bardrop commented Nov 25, 2026

Copy link
Copy Markdown

Or and Xor panic on amd64 and arm64 when the other bitmap has no words and there are no extra bitmaps:

var a, empty bitmap.Bitmap
a.Set(3)
a.Or(empty) // panic: runtime error: index out of range [0] with length 0

max is not 0 here, because a has words, so the early return is not taken and &other[0] is evaluated. The noasm build and the variadic form (a.Or(empty, empty), via foldEach) already handle this. An empty bitmap is easy to get: it is the zero value, and And shrinks its result to zero words when one side is empty.

The fix returns early when other is empty and there is nothing in extra.

The new tests panic before the change on arm64 and pass after it. go test ./... and go test -tags noasm . pass on arm64, and GOARCH=amd64 go test . passes under Rosetta (which does not report AVX, so the AVX paths there are the same one-line change but were not run).

Same report as #42, which closed without a merge.

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.

1 participant