Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUMBA_DISABLE_JIT causes an infinite loop in Structref instance creation. #7117

Open
bairdlampard534 opened this issue Jun 14, 2021 · 1 comment
Labels
bug - incorrect behavior Bugs: incorrect behavior bug

Comments

@bairdlampard534
Copy link

import os
os.environ['NUMBA_DISABLE_JIT'] = '1'

import numba
import numpy as np
from numba import njit
from numba.core import types
from numba.experimental import structref

@structref.register
class ValueType(types.StructRef):
    def preprocess_fields(self, fields):
        return tuple((name, types.unliteral(typ)) for name, typ in fields)
class Value(structref.StructRefProxy):
    def __new__(cls, val):
        return structref.StructRefProxy.__new__(cls, val)
    @property
    def val(self):
        return Value_get_val(self)
@njit
def Value_get_val(self):
    return self.val
structref.define_proxy(Value, ValueType, ["val"])
@njit
def div_by_zero(node):
    return node.val / 0
node1 = Value(54321)
div_by_zero(node1)
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
structref_mini_test.py in 
     35     return node.val / 0
     36 
---> 37 node1 = Value(54321)
     38 
     39 div_by_zero(node1)
structref_mini_test.py in __new__(cls, val)
     18 class Value(structref.StructRefProxy):
     19     def __new__(cls, val):
---> 20         return structref.StructRefProxy.__new__(cls, val)
     21 
     22     @property
~/anaconda3/envs/py38/lib/python3.8/site-packages/numba/experimental/structref.py in __new__(cls, *args)
    374             # cache it to attribute to avoid recompilation
    375             cls.__numba_ctor = ctor
--> 376         return ctor(*args)
    377 
    378     @property
~/anaconda3/envs/py38/lib/python3.8/site-packages/numba/experimental/structref.py in ctor(*args)
    371             @njit
    372             def ctor(*args):
--> 373                 return cls(*args)
    374             # cache it to attribute to avoid recompilation
    375             cls.__numba_ctor = ctor
... last 3 frames repeated, from the frame below ...
structref_mini_test.py in __new__(cls, val)
     18 class Value(structref.StructRefProxy):
     19     def __new__(cls, val):
---> 20         return structref.StructRefProxy.__new__(cls, val)
     21 
     22     @property
RecursionError: maximum recursion depth exceeded
@bairdlampard534 bairdlampard534 changed the title NUMBA_DISABLE_JIT leads infinite loop for Structref instance creation. NUMBA_DISABLE_JIT causes an infinite loop in Structref instance creation. Jun 14, 2021
@sklam sklam added needtriage bug bug - incorrect behavior Bugs: incorrect behavior and removed needtriage labels Jun 14, 2021
@sklam
Copy link
Member

sklam commented Jun 17, 2021

Thank you for reporting the issue. I can replicate it on mainline (84f2b5a).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - incorrect behavior Bugs: incorrect behavior bug
Projects
None yet
Development

No branches or pull requests

2 participants