numba: Operation "element in set" never returns
Bug: After a series of add and remove operations on a set in nopython mode the operation “in set” does not return and gets stuck at 100% CPU load.
Isolated code example:
import numba as nb
@ nb.njit()
def problem():
# init
openSet = set()
openSet.add((0, 0))
openSet.add((1, 0))
openSet.add((2, 0))
openSet.add((3, 0))
openSet.add((4, 0))
openSet.add((5, 0))
openSet.add((6, 0))
openSet.add((7, 0))
openSet.add((8, 0))
openSet.remove((2, 0))
openSet.add((2, 1))
openSet.remove((2, 1))
openSet.remove((4, 0))
openSet.add((5, 1))
openSet.add((4, 1))
openSet.remove((7, 0))
openSet.add((8, 1))
openSet.add((7, 1))
openSet.add((6, 1))
openSet.remove((8, 0))
openSet.remove((1, 0))
openSet.remove((0, 0))
openSet.remove((5, 0))
openSet.remove((6, 0))
openSet.remove((3, 0))
openSet.remove((7, 1))
openSet.add((8, 2))
openSet.add((7, 2))
openSet.add((6, 2))
openSet.remove((8, 1))
openSet.remove((6, 1))
openSet.add((5, 2))
openSet.remove((4, 1))
openSet.add((4, 2))
openSet.remove((5, 1))
openSet.remove((6, 2))
openSet.add((7, 3))
openSet.add((6, 3))
openSet.add((5, 3))
openSet.remove((7, 2))
openSet.add((8, 3))
openSet.remove((8, 2))
openSet.remove((4, 2))
openSet.add((4, 3))
openSet.add((3, 3))
openSet.remove((5, 2))
openSet.remove((7, 3))
openSet.add((8, 4))
openSet.add((7, 4))
print('About to check (6,4) in openSet')
return (6, 4) in openSet
if __name__ == "__main__":
print(problem())
print('DONE')
The code gets stuck with numba 0.52.0 with Python 3.8.5 on Ubuntu 20.04.1 LTS x86_64.
However, @esc on gitter.im also confirmed that the issue persists on OSX.
Isolated code example: https://github.com/icezyclon/astart-pathfinding/blob/main/isolated.py Original code example (from A* search): https://github.com/icezyclon/astart-pathfinding/blob/main/problem.py
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 41 (22 by maintainers)
Commits related to this issue
- Linear probe in sets only when appropriate. As title. Fixes #6543 — committed to stuartarchibald/numba by stuartarchibald 4 years ago
also, it is perhaps worth noting that
ctrl-c(SIGINT) will not kill the running process, onlyctrl-z(SIGSSTOP) followed bykill -9will.@stuartarchibald and I never got to the bottom of this fully. But we are certain there is a bug present, so I will re-label thhis accordingly.
The worst case, only happens under the special circumstances, if the set contains only in-use or deleted slots. If the load on the set is low, the runtime will be O(1) yes, since only a hash is needed to lookup an element.