Open
Description
There is a bug in function add.at
that causes core dump on certain unaligned arrays. Below is an example that shows the problem.
Reproducing code example:
import numpy as np
x_a = np.zeros(10, dtype='i8')
y_i = np.array(list(zip(np.arange(10), np.arange(10), np.ones(10, dtype='i1'))), dtype=[('a', 'i4'), ('b', 'i4'), ('c', 'i1')])
a_idx_i = np.arange(10, dtype='i8')
# the next line results in *core dump* with the following error msg:
# python: numpy/core/src/multiarray/lowlevel_strided_loops.c.src:823: _aligned_cast_int_to_long: Assertion `npy_is_aligned(src, __builtin_offsetof(struct {char c; npy_int v;}, v))' failed.
# Aborted
np.add.at(x_a, a_idx_i, y_i['b'])
Note, that the code above works without any errors if one changes type i4
to i8
in the definition of y_i
or removes the field c
from the definition of y_i
.
Error message:
python: numpy/core/src/multiarray/lowlevel_strided_loops.c.src:823: _aligned_cast_int_to_long: Assertion `npy_is_aligned(src, __builtin_offsetof(struct {char c; npy_int v;}, v))' failed.
Aborted
Numpy/Python version information:
('1.15.4', '2.7.15 |Anaconda custom (64-bit)| (default, Oct 10 2018, 21:32:13) \n[GCC 7.3.0]')