In-place `Quantity` operations with scalars and arrays can cause segmentation faults with `numpy`>=1.21
See original GitHub issueDescription
Trying to add in-place an array Quantity
to a scalar Quantity
should produce a ValueError
(but see also #10072). However, with numpy
>=1.21 it produces a segmentation fault, at least on Linux.
Suppose the following code snippet:
>>> from astropy import units as u
>>> scalar = 1*u.m
>>> array = (2, 3)*u.m
>>> scalar += array
Behavior with numpy
<1.21
With astropy
5.0.4 (LTS) and numpy
<1.21:
ValueError: non-broadcastable output operand with shape () doesn't match the broadcast shape (2,)
Behavior with numpy
>=1.21
With astropy
5.0.4 (LTS) and numpy
>=1.21:
Segmentation fault (core dumped)
I have verified that the segmentation fault also happens with astropy
main
(2288ecd4e9c4d3722d72b7f4a6555a34f4f04fc7) and numpy
1.22.3.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Segmentation faults with numpy 1.21 package #627 - GitHub
The recently released 1.21 version of numpy will cause segmentation faults with the cctbx-base conda package. This affects Python versions 3.7 through 3.9....
Read more >Identify what's causing segmentation faults (segfaults)
Find out-of-bounds array references; Check shell limits; Use debuggers to diagnose segfaults. Overview. A segmentation fault (aka segfault) is a ...
Read more >Numpy Ctypes: Segmentation Fault. Passing arrays via pointer
I am trying to create a python interface to a C function with the following structure: (Full code can be ...
Read more >NumPy User Guide
Data-types can be used as functions to convert python numbers to array scalars (see the array scalar section for an.
Read more >Guide to NumPy
objects in place of the Python objects. The array-enhanced scalars inherit from the. Python objects they can replace and should act like ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Given that the segmentation fault indeed only occurs when the operation that is being attempted is invalid to begin with, I now agree that there is no need to address this any further.
Yes, indeed, let’s close this. Thanks for reporting, @eerovaher - now numpy is a bit better again!