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

thread_pool_generic::m_thread_data_cache alignment violation

    XMLWordPrintable

Details

    Description

      MariaDB Server would crash for me on bootstrap because of an alignment violation. The following patch highlights the problem and fixes the issue for me, but obviously it is not an acceptable fix:

      diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc
      index 9ed832dd1ed..23064581307 100644
      --- a/tpool/tpool_generic.cc
      +++ b/tpool/tpool_generic.cc
      @@ -129,7 +129,7 @@ enum worker_wake_reason
       
       
       /* A per-worker  thread structure.*/
      -struct alignas(CPU_LEVEL1_DCACHE_LINESIZE)  worker_data
      +struct worker_data
       {
         /** Condition variable to wakeup this worker.*/
         std::condition_variable m_cv;
      @@ -179,16 +179,6 @@ struct alignas(CPU_LEVEL1_DCACHE_LINESIZE)  worker_data
           m_state(NONE),
           m_task_start_time()
         {}
      -
      -  /*Define custom new/delete because of overaligned structure. */
      -  static void *operator new(size_t size)
      -  {
      -    return aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE);
      -  }
      -  static void operator delete(void* p)
      -  {
      -    aligned_free(p);
      -  }
       };
       
      

      I also tried to define similar alignment and allocation operators for class thread_pool_generic, but that did not fix the problem.

      The misalignment tripped a 256-bit store on a 128-bit aligned address, apparently related to the initialization of cache<worker_data>::m_cv and possibly some neighboring data member, invoking the movaps instruction on an ymm register.

      Attachments

        Issue Links

          Activity

            People

              wlad Vladislav Vaintroub
              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.