* [PATCH v3] locale: align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32 arrays to uint16_t and uint32_t respectively
@ 2021-04-01 19:37 Lirong Yuan
2021-05-03 14:33 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Lirong Yuan @ 2021-04-01 19:37 UTC (permalink / raw)
To: libc-alpha; +Cc: adhemerval.zanella, schwab, stanshebs, scw, Lirong Yuan
steps to reproduce the problem: compile a program that uses ctype functions such as “isspace” for aarch64 with UBSan flag “-fsanitize=undefined” and run it on x86_64 machines with qemu user mode emulation.
observed behavior: UndefinedBehaviorSanitizer reports misaligned-pointer-use in the program.
solution: align the arrays defined in locale/C-ctype.c with correct data types as defined in ctype/ctype.h.
test suite regressions: none.
---
locale/C-ctype.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index bffdbedad0..da2c8cc33c 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -18,6 +18,7 @@
#include "localeinfo.h"
#include <endian.h>
+#include <stdalign.h>
#include <stdint.h>
#include "C-translit.h"
@@ -30,7 +31,7 @@
In the `_nl_C_LC_CTYPE_class' array the value for EOF (== -1)
is set to always return 0 and the conversion arrays return EOF. */
-const char _nl_C_LC_CTYPE_class[768] attribute_hidden =
+alignas(uint16_t) const char _nl_C_LC_CTYPE_class[768] attribute_hidden =
/* 0x80 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x86 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x8c */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
@@ -96,7 +97,7 @@ const char _nl_C_LC_CTYPE_class[768] attribute_hidden =
/* 0xf4 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xfa */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
;
-const char _nl_C_LC_CTYPE_class32[1024] attribute_hidden =
+alignas(uint32_t) const char _nl_C_LC_CTYPE_class32[1024] attribute_hidden =
/* 0x00 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x03 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x06 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
--
2.31.0.208.g409f899ff0-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] locale: align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32 arrays to uint16_t and uint32_t respectively
2021-04-01 19:37 [PATCH v3] locale: align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32 arrays to uint16_t and uint32_t respectively Lirong Yuan
@ 2021-05-03 14:33 ` Florian Weimer
2021-05-03 15:08 ` Lirong Yuan
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2021-05-03 14:33 UTC (permalink / raw)
To: Lirong Yuan via Libc-alpha; +Cc: Lirong Yuan, schwab, scw
* Lirong Yuan via Libc-alpha:
> steps to reproduce the problem: compile a program that uses ctype functions such as “isspace” for aarch64 with UBSan flag “-fsanitize=undefined” and run it on x86_64 machines with qemu user mode emulation.
>
> observed behavior: UndefinedBehaviorSanitizer reports misaligned-pointer-use in the program.
>
> solution: align the arrays defined in locale/C-ctype.c with correct data types as defined in ctype/ctype.h.
>
> test suite regressions: none.
I've pushed this patch for you with a reworded commit message and minor
formatting changes. Thanks.
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] locale: align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32 arrays to uint16_t and uint32_t respectively
2021-05-03 14:33 ` Florian Weimer
@ 2021-05-03 15:08 ` Lirong Yuan
0 siblings, 0 replies; 3+ messages in thread
From: Lirong Yuan @ 2021-05-03 15:08 UTC (permalink / raw)
To: Florian Weimer; +Cc: Lirong Yuan via Libc-alpha, Andreas Schwab, Shu-Chun Weng
Thank you Florian!
Regards,
Lirong
On Mon, May 3, 2021 at 7:33 AM Florian Weimer <fweimer@redhat.com> wrote:
> * Lirong Yuan via Libc-alpha:
>
> > steps to reproduce the problem: compile a program that uses ctype
> functions such as “isspace” for aarch64 with UBSan flag
> “-fsanitize=undefined” and run it on x86_64 machines with qemu user mode
> emulation.
> >
> > observed behavior: UndefinedBehaviorSanitizer reports
> misaligned-pointer-use in the program.
> >
> > solution: align the arrays defined in locale/C-ctype.c with correct data
> types as defined in ctype/ctype.h.
> >
> > test suite regressions: none.
>
> I've pushed this patch for you with a reworded commit message and minor
> formatting changes. Thanks.
>
> Florian
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-03 15:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 19:37 [PATCH v3] locale: align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32 arrays to uint16_t and uint32_t respectively Lirong Yuan
2021-05-03 14:33 ` Florian Weimer
2021-05-03 15:08 ` Lirong Yuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).