question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In-place `Quantity` operations with scalars and arrays can cause segmentation faults with `numpy`>=1.21

See original GitHub issue

Description

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:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
eerovahercommented, Jun 8, 2022

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.

1reaction
mhvkcommented, Jun 8, 2022

Yes, indeed, let’s close this. Thanks for reporting, @eerovaher - now numpy is a bit better again!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found