lemire / fastrand

Fast random number generation in an interval in Python: Up to 10x faster than random.randint.
Apache License 2.0
88 stars 12 forks source link

Seeding many generators causes fastrand to crash #13

Closed cloudbopper closed 4 years ago

cloudbopper commented 4 years ago

To reproduce:

python -m timeit -s 'import fastrand' 'fastrand.pcg32_seed(13)'

Fatal Python error: deallocating None

Current thread 0x00000001183f3dc0 (most recent call first):
  File "<timeit-src>", line 6 in inner
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/timeit.py", line 176 in timeit
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/timeit.py", line 222 in autorange
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/timeit.py", line 324 in main
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/timeit.py", line 374 in <module>
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85 in _run_code
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193 in _run_module_as_main
zsh: abort      python -m timeit -s 'import fastrand' 'fastrand.pcg32_seed(13)'

Or from within python:

import fastrand; rngs = [fastrand.pcg32_seed(i) for i in range(100000)]

Fatal Python error: deallocating None

Current thread 0x0000000116acadc0 (most recent call first):
  File "<stdin>", line 1 in <module>
zsh: abort      python

Verified that it happens on multiple OSes (MacOS, ScientificLinux).

lemire commented 4 years ago

Verified. It is a real bug. I don't know how to fix it.

lemire commented 4 years ago

I see how to fix it now.