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

PERFORMANCE_SCHEMA unit tests fail due to memory misalignment

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

          marko Marko Mäkelä created issue -
          marko Marko Mäkelä made changes -
          Field Original Value New Value
          issue.field.resolutiondate 2022-03-16 10:23:43.0 2022-03-16 10:23:43.068
          marko Marko Mäkelä made changes -
          Fix Version/s 10.2.44 [ 27514 ]
          Fix Version/s 10.3.35 [ 27512 ]
          Fix Version/s 10.4.25 [ 27510 ]
          Fix Version/s 10.5.16 [ 27508 ]
          Fix Version/s 10.6.8 [ 27506 ]
          Fix Version/s 10.7.4 [ 27504 ]
          Fix Version/s 10.8.3 [ 27502 ]
          Fix Version/s 10.2 [ 14601 ]
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          Fix Version/s 10.5 [ 23123 ]
          Fix Version/s 10.6 [ 24028 ]
          Fix Version/s 10.7 [ 24805 ]
          Fix Version/s 10.8 [ 26121 ]
          Fix Version/s 10.9 [ 26905 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          marko Marko Mäkelä added a comment - I had missed another pfs_malloc() unit test stub .

          People

            marko Marko Mäkelä
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.