Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-28091

PERFORMANCE_SCHEMA unit tests fail due to memory misalignment

    XMLWordPrintable

    Details

      Description

      On my system, 3 unit tests for performance_schema failed with SIGSEGV, on MariaDB Server 10.9. The reason turned out to be that the SIMD instruction MOVAPS was executed in create_thread() on a pointer that was only aligned to 128 bits (16 bytes), not the required 256 or 512 bits.

      The reason turned out to be that the mocked up pfs_malloc() failed to return properly aligned memory (64 bytes or 512 bits in the case of AMD64):

      diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h
      index 8a1f9216ba2..3d7d818cc51 100644
      --- a/storage/perfschema/unittest/stub_pfs_global.h
      +++ b/storage/perfschema/unittest/stub_pfs_global.h
      @@ -24,6 +24,9 @@
       #include <my_sys.h>
       #include <pfs_global.h>
       #include <string.h>
      +#ifdef HAVE_MEMALIGN
      +# include <malloc.h>
      +#endif
       
       bool pfs_initialized= false;
       
      @@ -43,7 +46,15 @@ void *pfs_malloc(size_t size, myf)
         if (--stub_alloc_fails_after_count <= 0)
           return NULL;
       
      +#ifndef PFS_ALIGNEMENT
         void *ptr= malloc(size);
      +#elif defined HAVE_MEMALIGN
      +  void *ptr= memalign(PFS_ALIGNEMENT, size);
      +#elif defined HAVE_ALIGNED_MALLOC
      +  void *ptr= _aligned_malloc(size, PFS_ALIGNEMENT);
      +#else
      +# error "Missing implementation"
      +#endif
         if (ptr != NULL)
           memset(ptr, 0, size);
         return ptr;
      

        Attachments

          Activity

            People

            Assignee:
            marko Marko Mäkelä
            Reporter:
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.