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

Empty list of lists crashes at runtime with njit #8878

Open
GaidaiIgor opened this issue Apr 4, 2023 · 1 comment
Open

Empty list of lists crashes at runtime with njit #8878

GaidaiIgor opened this issue Apr 4, 2023 · 1 comment
Labels
bug - incorrect behavior Bugs: incorrect behavior bug - typing Bugs: occuring at typing time

Comments

@GaidaiIgor
Copy link

GaidaiIgor commented Apr 4, 2023

The following code reproduces the issue:

from numba import njit
import numpy as np


@njit
def test():
    a = [[0, 1]]
    a.clear()
    b = np.array(a)


test()

This code crashes with the following error message:

IndexError: getitem out of range

Without @njit this code finishes successfully.

Numba version: 0.56.4
Numpy version: 1.23.5
Python version: 3.10
OS: Windows 10

@GaidaiIgor GaidaiIgor changed the title Valid Python code crashes at runtime with njit Empty list of lists crashes at runtime with njit Apr 4, 2023
@stuartarchibald
Copy link
Contributor

Thanks for the report and MWR. This reproduces exactly as described. Numba infers that a is a list-of-lists-of-integers from which it then determines that b must be a 2d array of integers, i.e. the a.clear() isn't acknowledged. I'd guess it's this which leads to the IndexError as the np.array() constructor code expects a list-of-lists but just gets a list.

@stuartarchibald stuartarchibald added bug - incorrect behavior Bugs: incorrect behavior bug - typing Bugs: occuring at typing time labels Apr 4, 2023
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 - typing Bugs: occuring at typing time
Projects
None yet
Development

No branches or pull requests

2 participants