Visitar URL original
Insufficient sigaltstack size used by CPython prevents extensions from using new ISA · Issue #91124 · python/cpython · GitHub
Skip to content

Insufficient sigaltstack size used by CPython prevents extensions from using new ISA #91124

Description

@oleksandr-pavlyk
BPO 46968
Nosy @vstinner, @ambv, @pablogsal, @miss-islington, @oleksandr-pavlyk
PRs
  • bpo-46968: Query altstack size dynamically on Linux kernel >=5.14 #31789
  • bpo-46968: Add os.sysconf_names['SC_MINSIGSTKSZ'] #31824
  • [3.10] bpo-46968: Fix faulthandler for Sapphire Rapids Xeon (GH-31789) #31830
  • [3.9] bpo-46968: Fix faulthandler for Sapphire Rapids Xeon (GH-31789) #31831
  • bpo-46968: Check for 'sys/auxv.h' in the configure script #31961
  • [3.10] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-1961) #31974
  • [3.9] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961) #31975
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-03-18.13:33:30.380>
    created_at = <Date 2022-03-09.19:07:02.730>
    labels = ['extension-modules', 'type-bug', '3.9', '3.10', '3.11']
    title = 'Insufficient sigaltstack size used by CPython prevents extensions from using new ISA'
    updated_at = <Date 2022-03-18.14:15:32.541>
    user = 'https://github.com/oleksandr-pavlyk'

    bugs.python.org fields:

    activity = <Date 2022-03-18.14:15:32.541>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-18.13:33:30.380>
    closer = 'pablogsal'
    components = ['Extension Modules']
    creation = <Date 2022-03-09.19:07:02.730>
    creator = 'oleksandr-pavlyk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46968
    keywords = ['patch']
    message_count = 21.0
    messages = ['414809', '414938', '414939', '414941', '414943', '414949', '414950', '414957', '414960', '414965', '415402', '415403', '415404', '415405', '415406', '415407', '415483', '415487', '415496', '415497', '415500']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'lukasz.langa', 'lkollar', 'pablogsal', 'miss-islington', 'oleksandr-pavlyk']
    pr_nums = ['31789', '31824', '31830', '31831', '31961', '31974', '31975']
    priority = None
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46968'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. oleksandr-pavlyk commented on Mar 9, 2022

      oleksandr-pavlykmannequin
      MannequinAuthor

      The following snippet illustrates request by an extension to use AMX registers:

      // no increase sigaltstack size fix will not wark till we fix python
      void enable_amx_no_fix()
      {
      
          unsigned long bitmask;
          long rc;
      
          rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA);
          if (rc) {
              printf("The kernel rejects the AMX use.\n");
              printf("errno %d\n",errno);
          } else {
              printf("The kernel allows to use AMX.\n");
          }
      
      
          rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_PERM, &bitmask);
      
          if (rc) {
              printf("rc error\n");
          } else  {
              if (( bitmask & XFEATURE_MASK_XTILEDATA) == 0){
                  printf("verify AMX permission faild bitmask %ld\n",bitmask);
              }
      
          }
      }
      

      This request fails on the account of too small a size for sigaltstack used by CPython allocated in Modules/faulthandler.c

      The stack size used is 2*SIGSTKSZ, and does not take hardware capabilities into account.

      Linux kernel 5.14 adds support to query minimum size of sigaltstack dynamically via getauxval(AT_MINSIGSTKSZ).

      AMX support is added in Linux kernel 5.16

      CPython should make use of this when built against more recent Linux kernels.

    2. 20 remaining items

    3. pablogsal commented on Mar 17, 2022

      @pablogsal
      Member

      The configure file is checking for "linux/auxvec.h"

      checking linux/auxvec.h usability... yes

      but the code is including "sys/auxvec.h"

    4. pablogsal commented on Mar 17, 2022

      @pablogsal
      Member

      The code is assuming that if linux/auxvec.h then sys/auxv.h will be available, which is wrong.

    5. pablogsal commented on Mar 17, 2022

      @pablogsal
      Member

      This may be quite bad, because this means that 3.10 and 3.9 doesn't build in CentOS 6, which is used for manylinux2010 wheels

    6. vstinner commented on Mar 18, 2022

      @vstinner
      Member

      Commit 393e2bf has broken CPython in RedHat 6

      Too bad that we want to support RHEL 6 but have no buildbot for that.

    7. miss-islington commented on Mar 18, 2022

      @miss-islington
      Contributor

      New changeset 8e3fde7 by Pablo Galindo Salgado in branch 'main':
      bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961)
      8e3fde7

    8. pablogsal commented on Mar 18, 2022

      @pablogsal
      Member

      New changeset a12ef81 by Pablo Galindo Salgado in branch '3.9':
      [3.9] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961). (GH-31975)
      a12ef81

    9. pablogsal commented on Mar 18, 2022

      @pablogsal
      Member

      New changeset 6fd9737 by Pablo Galindo Salgado in branch '3.10':
      [3.10] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961). (GH-31974)
      6fd9737

    10. vstinner commented on Mar 18, 2022

      @vstinner
      Member

      Thanks for the fix Pablo.

    11. transferred this issue fromon Apr 10, 2022
    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

      3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifeextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions