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

parallel list comprehension corruption #4579

Closed
2 tasks done
stuartarchibald opened this issue Sep 17, 2019 · 3 comments
Closed
2 tasks done

parallel list comprehension corruption #4579

stuartarchibald opened this issue Sep 17, 2019 · 3 comments

Comments

@stuartarchibald
Copy link
Contributor

Reporting a bug

This:

from numba import njit, prange, gdb
import numpy as np

@njit(parallel=True)
def get_lengths_parallel(xx):
    return [np.int32(len(xx[i])) for i in prange(len(xx))]

get_lengths_parallel([np.array([1,2,3],dtype=np.int64) for i in range(1000000)])

is corrupting state somewhere, sometimes SIGSEGV, sometimes double free and SIGABRT, sometimes realloc(): invalid next size and SIGSEGV. Issue seems to be invariant of threading layer.

@mroeschke
Copy link

mroeschke commented Jul 26, 2020

Just wanted to note that this bug still exists in 0.50.1 and there might be subtle (but related) differences when using list comprehension vs list.append

In [5]: import numpy as np

In [6]: import numba

In [7]: numba.__version__
Out[7]: '0.50.1'

In [3]: @numba.jit(nopython=True, parallel=True)
   ...: def f(x):
   ...:     return [np.arange(i) for i in numba.prange(x)]

In [4]: f(4)
python(6352,0x700001bec000) malloc: Double free of object 0x7fbe6a494110
python(6352,0x700001c6f000) malloc: Double free of object 0x7fbe6a494110
python(6352,0x700001bec000) malloc: *** set a breakpoint in malloc_error_break to debug
python(6352,0x700001c6f000) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

In [3]: @numba.jit(nopython=True, parallel=True)
   ...: def f(x):
   ...:     lst = []
   ...:     for i in numba.prange(x):
   ...:         lst.append(np.arange(i))
   ...:     return lst
   ...:

In [4]: f(4)
python(6370,0x70000d504000) malloc: *** error for object 0x7febad438f20: pointer being realloc'd was not allocated
python(6370,0x70000d504000) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

@esc
Copy link
Member

esc commented Jul 27, 2020

@mroeschke thanks for updating the issue and adding more information.

@stuartarchibald
Copy link
Contributor Author

Closing, this is unsupported as containers such as list as not threadsafe. Noted in docs:
https://numba.readthedocs.io/en/stable/user/parallel.html#unsupported-operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants