8000 Bug in function add.at (core dump) · Issue #13317 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Bug in function add.at (core dump) #13317

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

Open
dmbelov opened this issue Apr 12, 2019 · 4 comments
Open

Bug in function add.at (core dump) #13317

dmbelov opened this issue Apr 12, 2019 · 4 comments

Comments

@dmbelov
Copy link
Contributor
dmbelov commented Apr 12, 2019

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]')

@dmbelov
Copy link
Contributor Author
dmbelov commented Apr 12, 2019

Please close this ticket: I've just checked this bug does not appear in NumPy 1.16.2; so it was fixed.

@seberg
Copy link
Member
seberg commented Apr 13, 2019

Still seems to be there, the asserts are just not active in the release versions. I guess the results are likely correct in any case. @ahaldane do you know what is going on here directly?

@seberg seberg reopened this Apr 13, 2019
@ahaldane
Copy link
Member

This is code which I touched in 1.16, in #6377, #12677, #12626.

If I recall correctly, I actually found bugs in the old code where it was possible for numpy to do misaligned operations in some strange cases, which was fixed in those PRs. So it is quite possible this bug was fixed there.

I will take a closer look in a bit

@mattip
Copy link
Member
mattip commented May 16, 2019

@ahaldane can we close this?

No: Can still be reproduced with debug version 2024-01

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

5 participants
0