Skip to content

Commit

Permalink
MDEV-22578 thread_pool_info crashes with clang6, using SSE instructio…
Browse files Browse the repository at this point in the history
…ns on unaligned memory

Apparently, in stats_reset_table(), the innocuous

  memset(&group->counters, 0, sizeof(group->counters));

is converted by clang to SSE2 instructions.

The problem is that "group" is not correctly aligned,
despite  MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) in the thread_group_t
declaration.

It is not aligned because it was allocated with my_malloc, since
commit fd9f163, MDEV-5205. Previously all_groups was a
statically allocated array.

Fix is to remove MY_ALIGNED, and pad the struct instead.
  • Loading branch information
vaintroub committed May 15, 2020
1 parent f2a9445 commit 69077de
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sql/threadpool_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct thread_group_counters_t
ulonglong polls[2];
};

struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) thread_group_t
struct thread_group_t
{
mysql_mutex_t mutex;
connection_queue_t queues[NQUEUES];
Expand All @@ -145,6 +145,7 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) thread_group_t
bool shutdown;
bool stalled;
thread_group_counters_t counters;
char pad[CPU_LEVEL1_DCACHE_LINESIZE];
};

#define TP_INCREMENT_GROUP_COUNTER(group,var) do {group->counters.var++;}while(0)
Expand Down

0 comments on commit 69077de

Please sign in to comment.