Discussion:
[PATCH] BUG/CRITICAL: SIGBUS crash on aarch64
Paul Martin
2018-11-14 15:33:02 UTC
Permalink
Atomic operations on aarch64 (arm64) have to be aligned to 8 byte
boundaries (same size as a pointer type), otherwise a SIGBUS is raised.

Because the variable ts here isn't guaranteed to be aligned due to the
various data_size adjustments, make sure that data_size is always
incremented by a minimum of sizeof(int *) rather than sizeof(int).

Program received signal SIGBUS, Bus error.
0x0000aaaaaab1176c in process_store_rules (s=***@entry=0xaaaaaae01060,
rep=0xaaaaaae010d0, rep=0xaaaaaae010d0, an_bit=8388608)
at src/stream.c:1609
1609 HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
(gdb) bt
%0 0x0000aaaaaab1176c in process_store_rules (s=***@entry=0xaaaaaae01060,
rep=0xaaaaaae010d0, rep=0xaaaaaae010d0, an_bit=8388608)
at src/stream.c:1609
%1 0x0000aaaaaab18898 in process_stream (t=<optimized out>,
context=0xaaaaaae01060, state=<optimized out>) at src/stream.c:2054
%2 0x0000aaaaaabb0220 in process_runnable_tasks () at src/task.c:421
%3 0x0000aaaaaab51b40 in run_poll_loop () at src/haproxy.c:2609
%4 run_thread_poll_loop (data=<optimized out>) at src/haproxy.c:2674
%5 0x0000aaaaaaac715c in main (argc=<optimized out>, argv=0xfffffffff290)
at src/haproxy.c:3286
---
include/proto/stick_table.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index 40bb8ca6..6e39ad47 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -64,7 +64,7 @@ static inline int stktable_type_size(int type)
switch(type) {
case STD_T_SINT:
case STD_T_UINT:
- return sizeof(int);
+ return sizeof(int *);
case STD_T_ULL:
return sizeof(unsigned long long);
case STD_T_FRQP:
--
2.19.1
Paul Martin
2018-11-15 09:48:20 UTC
Permalink
Oops, you're right indeed.
I'm not sure I'm a big fan of special-casing STD_T_UINT. For example,
STD_T_FRQP is probably 12bytes too, so it'd be a problem.
Can you test the (untested, but hopefully right) patch attached ?
Yes, your patch works on aarch64 too.
--
Paul Martin http://www.codethink.co.uk/
Senior Software Developer, Codethink Ltd.
Willy Tarreau
2018-11-15 13:26:59 UTC
Permalink
Willy, can you push the attached patch ?
Applied, thanks. I've just slightly edited it to put parenthesis around
+#define round_ptr_size(i) ((i + (sizeof(void *) - 1)) &~ (sizeof(void *) - 1))
so that if someone decides to do round_ptr_size(x & mask) he doesn't end up
doing (x & (mask + sizeof(void*)-1)) but ((x & mask) + sizeof(...))

:-)

Willy

Loading...