GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GCC 15.1.1 compiles NumPy, but the tests segfault. · Issue #28991 · numpy/numpy

GCC 15.1.1 compiles NumPy, but the tests segfault. #28991

New issue
Copy link
New issue
Copy link
Closed
#29094
Closed
GCC 15.1.1 compiles NumPy, but the tests segfault.#28991
#29094
Copy link
Milestone
2.4.0 release

Description

@charris
charris
opened on May 16, 2025
Issue body actions

The failure is at _core/tests/test_half.py, line 54. I assume that is a problem with GCC 15.1.1, as it has had a rocky start. Has anyone else had problems? The problem doesn't seem to be in NumPy, it was compiling and running fine before I upgraded Fedora to 42.

Activity

  1. charris commented on May 17, 2025

    @charris
    charris
    on May 17, 2025
    MemberAuthor
    More actions

    The problem seems to be in boolean indexing.

  2. ngoldbaum commented on May 18, 2025

    @ngoldbaum
    ngoldbaum
    on May 18, 2025
    Member
    More actions

    Can you share a gdb traceback?

  3. charris commented on May 18, 2025

    @charris
    charris
    on May 18, 2025
    MemberAuthor
    More actions

    Can you share a gdb traceback?

    I was going to wait on the next GCC 15 version. Fedora (and Linus!) jumped the gun in using 15 in a release.

  4. NiLuJe commented on May 25, 2025

    @NiLuJe
    NiLuJe
    on May 25, 2025
    More actions

    I can reproduce segfaults on a small chunk of the testsuite (and, well, in production, which is what led me to double-check ;p) with GCC 15.1.0 over here, too, FWIW (Gentoo Linux, x64, on a zen4 CPU). Everything passes w/ GCC 14.x (right now, 14.3.0).

    Will see about getting some traces in the next few days.

  5. thesamesam commented on May 26, 2025

    @thesamesam
    thesamesam
    on May 26, 2025
    Contributor
    More actions

    I was going to wait on the next GCC 15 version. Fedora (and Linus!) jumped the gun in using 15 in a release.

    Fedora only shipped it briefly before the final release. The next GCC 15 release will be in a couple of months, then it goes to yearly (same schedule as usual). It's best if it turns out to be a GCC bug to get it reported before that next one. Otherwise, relying on the fix being out there takes way longer.

  6. thesamesam commented on May 28, 2025

    @thesamesam
    thesamesam
    on May 28, 2025
    Contributor
    More actions

    I tried to reproduce this in the following environments:

    • on my regular Gentoo workstation using GCC trunk but with -O3 -march=znver2 -flto with our numpy-2.2.6 package's testsuite
    • in a clean Gentoo container running stable but with GCC 15 installed and in-use to build our numpy-2.5.5 package's testsuite
    • in a Fedora 42 container (fedora:42 with Docker) on a git clone of main using spin test
      and all of them worked.

    @NiLuJe Feel free to file a bug on the Gentoo side so we can dig into it a bit there and see if we can come up with something to share on this side if there's nothing obvious we find here. If you do, please include the testsuite results when run via the ebuild (inc. build.log) and emerge --info. Thanks!

    Reacted by NiLuJe
  7. NiLuJe commented on May 28, 2025

    @NiLuJe
    NiLuJe
    on May 28, 2025
    More actions
    • on my regular Gentoo workstation using GCC trunk but with -O3 -march=znver2 -flto with our numpy-2.2.6 package's testsuite

    That was an interesting observation!

    I'm using -O3 -march=native (so ~ znver4)... and, indeed, it passes w/ znver2, it passes w/ znver3.... and it fails with znver4!

    LTO doesn't affect the result, but, unsurprisingly (somewhat? I was under the impression that the buildsystem enforced O3 anyway?), -O3 does: it passes w/ -O2 -march=znver4.

    I'll file that on the Gentoo side w/ the logs.

  8. NiLuJe commented on May 28, 2025

    @NiLuJe
    NiLuJe
    on May 28, 2025
    More actions

    I'll file that on the Gentoo side w/ the logs.

    Here it is: https://bugs.gentoo.org/956770

  9. charris commented on May 28, 2025

    @charris
    charris
    on May 28, 2025
    MemberAuthor
    More actions

    I've found using -march=native triggers the error, as do -march=x86-64-v4 and -march=znver5. Omitting -march altogether works. For the record, I have an AMD Zen5 cpu.

    I'm suspecting a conflict with either meson or the dispatcher. The lesson might be: don't use -march.

  10. thesamesam commented on May 30, 2025

    @thesamesam
    thesamesam
    on May 30, 2025
    Contributor
    More actions

    Summarising findings from the Gentoo side: it's a numpy bug.

    Thread 1 "python3.13" received signal SIGSEGV, Segmentation fault.
    0x00007ffff47df6d9 in npy_memchr (haystack=0x7fffe8835d07 "", needle=0 '\000', stride=1, size=514, psubloopsize=0x7fffffffa160, invert=1) at ../numpy-2.2.6/numpy/_core/src/multiarray/common.h:278
    278                     if (v != 0) {
    (gdb) bt
    #0  0x00007ffff47df6d9 in npy_memchr (haystack=0x7fffe8835d07 "", needle=0 '\000', stride=1, size=514, psubloopsize=0x7fffffffa160, invert=1) at ../numpy-2.2.6/numpy/_core/src/multiarray/common.h:278
    #1  array_boolean_subscript (self=self@entry=0x7fffec1c65b0, bmask=<optimized out>, order=order@entry=NPY_CORDER) at ../numpy-2.2.6/numpy/_core/src/multiarray/mapping.c:1022
    [...]
    

    Looking at npy_memchr, I see UBSAN gets suppressed at

    numpy/numpy/_core/src/multiarray/common.h

    Line 233 in 5ab56f6

    #ifdef __clang__
    (added for #21116).

    (It actually looks quite similar to what subversion was doing: https://bugs.gentoo.org/950271).

    Changing https://github.com/numpy/numpy/blob/main/numpy/_core/include/numpy/npy_cpu.h#L128 to set #define NPY_ALIGNMENT_REQUIRED 1 works for Kostadin who could hit it otherwise.

    I recommend ripping all of that out and always assuming NPY_ALIGNMENT_REQUIRED. You'll run into random issues like this otherwise with increasing frequency.

    Reacted by h-vetinari
  11. ngoldbaum commented on May 30, 2025

    @ngoldbaum
    ngoldbaum
    on May 30, 2025
    Member
    More actions

    Thanks for the deep dive! Ping @seberg - it looks like you added the suppression in 2022.

    Reacted by Sam James, Kostadin and Charles Harris
  12. seberg commented on May 30, 2025

    @seberg
    seberg
    on May 30, 2025
    Member
    More actions

    🤷 this is ancient code, I just added the ignore because the variable is supposed to be set when we know unaligned access is supported and also it clearly was supported on all systems UBSAN ever ran on.

    I don't care for keeping NPY_ALIGNEMENT_REQUIRED around (it probably makes a bit of a difference for structured dtypes only). It's just in one corner of NumPy and not used for a large chunk NumPy runs.

    While I doubt it is important, I do think that this did/does make some sense here (no idea how much), in subversion, and I am very sure I also saw it in linux kernel code.
    The pattern is 10+ years old in NumPy, and while I don't know if the define could be smarter, I doubt we will be the last project that runs into it.

  13. charris commented on May 30, 2025

    @charris
    charris
    on May 30, 2025
    MemberAuthor
    More actions

    Could be that gcc is using SIMD instructions that expect alignment.

  14. thesamesam commented on May 30, 2025

    @thesamesam
    thesamesam
    on May 30, 2025
    Contributor
    More actions

    Could be that gcc is using SIMD instructions that expect alignment.

    It's precisely that, yeah. GCC will even peel for alignment now to handle misaligned workloads.

    While I doubt it is important, I do think that this did/does make some sense here (no idea how much), in subversion, and I am very sure I also saw it in linux kernel code.

    Right, it was absolutely a reasonable thing to do and it would've given a nice boost in the past. On the other hand, it's always a pain when you start debugging something and realise it's an #ifdef away from being legal ;)

    It's just at odds with expecting compilers to autovectorise things these days. I recommend just dropping all of it, and if there's performance regressions, we can look into those if-and-when.

  15. charris
    added this to the 2.3.0 release milestone on May 30, 2025
  16. charris
    added 2 commits that reference this issue on Jun 5, 2025

    MAINT: Fix for segfaults with GCC 15

    75a2e27

    MAINT: Fix for segfaults with GCC 15

    01db43d
  17. charris
    modified the milestones: 2.3.0 release, 2.4.0 release on Jun 6, 2025
  18. charris
    closed this as completedin #29094on Jun 8, 2025
  19. joy2myself
    added a commit that references this issue on Jul 21, 2025

    ENH: Convert unary from C universal intrinsics to C++ using Highway (#19

    This issue will close once commit 3f5dccf is merged into the 'rvv' branch.
    3f5dccf
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 2.4.0 release

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.