Skip to content

Iteration Bug fix: - #85

Closed
molaxx wants to merge 1 commit into
MagicStack:masterfrom
molaxx:master
Closed

molaxx wants to merge 1 commit into
MagicStack:masterfrom
molaxx:master

Conversation

@molaxx

@molaxx molaxx commented May 21, 2022

Copy link
Copy Markdown

Assumption that there are max number of levels 7 is wrong, a collision at the 7 level creates a collision node in the 8th level, this causes iteration to stop prematurely.

for reproduction (before the fix):
PYTHONHASHSEED=0 python <<EOF
import itertools
import immutables
import random
seed=b"b\xe6\xe2\x82\xe5\xc1e|"
r = random.Random(seed)
a = immutables.Map(
zip(
(r.randrange(0, 10000000000) for i in range(820000)),
itertools.repeat(None, 820000),
)
)
len1 = len(a)
len2 = len(tuple(a))
if len1 != len2:
print(f"BADDDD seed:{seed} len(a)={len1} len(tuple(a))={len2}")

EOF

Assumption that there are max number of levels 7 is wrong, a collision at the 7 level creates a collision node in the 8th level, this causes iteration to stop prematurely.
for reproduction:
PYTHONHASHSEED=0 python <<EOF
import itertools
import immutables
import random
seed=bbxe6xe2x82xe5xc1e
@molaxx molaxx mentioned this pull request May 21, 2022
@1st1

1st1 commented May 22, 2022

Copy link
Copy Markdown
Member

I've created a new PR that adds a test #87

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.

2 participants