On Sun, May 05, 2019 at 11:36:46PM +0500, ???? ??????? wrote:
> with sanitizer:
>  27 init_STG_POOL 00000800  0000000000afb3a0  0000000000afb3a0  006fa3a0
> 2**5
>                   CONTENTS, ALLOC, LOAD, DATA
>  28 init_STG_LOCK 000002c0  0000000000afbba0  0000000000afbba0  006faba0
> 2**5
>                   CONTENTS, ALLOC, LOAD, DATA
>  29 init_STG_REGISTER 000023c0  0000000000afbe60  0000000000afbe60
> 006fae60  2**5
>                   CONTENTS, ALLOC, LOAD, DATA
>  30 init_STG_PREPARE 00000100  0000000000afe220  0000000000afe220
> 006fd220  2**5
>                   CONTENTS, ALLOC, LOAD, DATA
(...)

> without sanitizer:
>  25 init_STG_POOL 00000100  00000000005c3090  00000000005c3090  001c2090
> 2**3
>                   CONTENTS, ALLOC, LOAD, DATA
>  26 init_STG_LOCK 00000058  00000000005c3190  00000000005c3190  001c2190
> 2**3
>                   CONTENTS, ALLOC, LOAD, DATA
>  27 init_STG_REGISTER 00000478  00000000005c31e8  00000000005c31e8
> 001c21e8  2**3
>                   CONTENTS, ALLOC, LOAD, DATA
>  28 init_STG_PREPARE 00000020  00000000005c3660  00000000005c3660
> 001c2660  2**3


Bingo! Alignment was forced to 2^5 when using the sanitizer, which
causes it not only to detect issues, but may even cause some crashes
upon startup when trying to dereference padding as function pointers.

You may want to try to apply the following change, though I'm not much
convinced :

diff --git a/include/common/initcall.h b/include/common/initcall.h
index 6da752c..f19d91c 100644
--- a/include/common/initcall.h
+++ b/include/common/initcall.h
@@ -104,7 +104,7 @@ struct initcall {
         __GLOBL(__start_init_##stg );                              \
        __GLOBL(__stop_init_##stg );                               \
        static const struct initcall *__initcb_##linenum           \
-           __attribute__((__used__,HA_SECTION(stg))) =            \
+           __attribute__((__used__,aligned(8),HA_SECTION(stg))) = \
                (stg < STG_SIZE) ? &(const struct initcall) {      \
                .fct = (void (*)(void *,void *,void *))function,   \
                .arg1 = (void *)(a1),                              \

Otherwise you may simply prefer to build with USE_OBSOLETE_LINKER=1
when building with the address sanitizer as this one will make use of
larger linked lists but will be insensitive to alignment.

Cheers,
willy

Reply via email to