Skip to content

BUG: Segmentation fault when doing a "Bitwise OR" on a np.longdouble with a None value #26767

Closed

Description

@BergLucas

Describe the issue:

I was working on Pynguin, an automated unit test generation tool for Python, and the tool found that Numpy creates a segmentation fault when doing a "Bitwise OR" on a np.longdouble with a None value.

Reproduce the code example:

import numpy

numpy.longdouble() | None

Error message:

Segmentation fault (core dumped)

Python and NumPy Versions:

2.0.0
3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0]

Runtime Environment:

[{'numpy_version': '2.0.0',
'python': '3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0]',
'uname': uname_result(system='Linux', node='lucas-hp', release='6.8.11-200.fc39.x86_64', version='#1 SMP PREEMPT_DYNAMIC Sun May 26 20:05:41 UTC 2024', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Zen',
'filepath': '/home/lucas/.conda/envs/pynguin-for-ML-libraries/lib/python3.10/site-packages/numpy.libs/libscipy_openblas64_-99b71e71.so',
'internal_api': 'openblas',
'num_threads': 12,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.27'}]

Context for the issue:

It's not a particularly serious bug, but an exception is thrown when the same code is run with a np.double, so fixing the bug might be a good idea to make it more user-friendly in the event of a user error and to make it more consistent with other Numpy types.

Activity

  1. eendebakpt commented on Jun 23, 2024

    @eendebakpt
    Contributor

    I can confirm the bug under Windows. Also with a bitwise &.

  2. added this to the 2.0.1 release milestone on Jun 25, 2024
  3. seberg commented on Jun 25, 2024

    @seberg
    Member

    Just to note: This is not a regression. The reason is an infinite recursion due to NumPy being opportunistic when it comes to object dtype loops and that doesn't work for longdouble.
    A bit annoying, "scalarmath" has appropriate logic, but the generic implementation that just forwards it to the array one doesn't.
    (There is likely no ideal logic, it would almost be nice to just notice the recursion directly, or maybe even put the logic into the ufunc loop. The problem is that the broken logic makes some other things magically work and we would break those by changing it the easy way).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions