Improved patch. Ensuring alignment of the struct was not enough, since we're aliasing to an address (offset of "*read") into one of its buffers.
The additional change below ensures that "read" is always a multiple of 8. As I type this, I realized that I can propose a more local (i.e., more maintainable) change that does not depend on the alignment of the buffer. but otherwise equivalent. Coming up... >From 3a99ee874593d2e59c42ad518ee197c36bb94e58 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Mon, 23 Mar 2009 08:47:02 +0100 Subject: [PATCH] avoid bus error due to mis-aligned "shared_memory" access * include/corosync/ipc_gen.h (REQ_SIZE, RES_SIZE, RE DISPATCH_SIZE): Define to be a power of 2. This ensures that res_buffer and dispatch_buffer are sufficiently well aligned for e.g., the sparc ABI. Improved alignment can also improve performance. * lib/coroipcc.c (memcpy_swrap): Ensure that *read is always a multiple of 8. --- include/corosync/ipc_gen.h | 6 +++--- lib/coroipcc.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/corosync/ipc_gen.h b/include/corosync/ipc_gen.h index 3e42e85..051b027 100644 --- a/include/corosync/ipc_gen.h +++ b/include/corosync/ipc_gen.h @@ -64,9 +64,9 @@ enum req_init_types { #define MESSAGE_REQ_CHANGE_EUID 1 #define MESSAGE_REQ_OUTQ_FLUSH 2 -#define REQ_SIZE 1000000 -#define RES_SIZE 1000000 -#define DISPATCH_SIZE 1000000 +#define REQ_SIZE (1024*1024) +#define RES_SIZE (1024*1024) +#define DISPATCH_SIZE (1024*1024) struct shared_memory { unsigned char req_buffer[REQ_SIZE]; diff --git a/lib/coroipcc.c b/lib/coroipcc.c index 47937ee..93b9af4 100644 --- a/lib/coroipcc.c +++ b/lib/coroipcc.c @@ -446,6 +446,12 @@ static void memcpy_swrap ( second_read); } *read = (*read + len) % (DISPATCH_SIZE); + + /* + * Ensure that *read is always 8-byte-aligned. + */ + *read += *read % 8; + *read %= DISPATCH_SIZE; } int original_flow = -1; -- 1.6.2.rc1.285.gc5f54 _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
