[PATCH] getty: Prevent clang from reading the G pointer before it is assigned
Bin Meng
bmeng.cn at gmail.com
Tue May 27 12:19:37 UTC 2025
It was observed that getty crashes on RISC-V 64-bit target, with the
busybox binary compiled by clang/LLVM 17 with -O2.
Change getty's INIT_G() to use XZALLOC_CONST_PTR() instead to defeat
the compiler optimization.
Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---
loginutils/getty.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 4581cc9f7..8a2928577 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -110,7 +110,7 @@ struct globals {
#define G (*ptr_to_globals)
#define INIT_G() do { \
- SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ XZALLOC_CONST_PTR(&ptr_to_globals, sizeof(G)); \
} while (0)
//usage:#define getty_trivial_usage
--
2.34.1
More information about the busybox
mailing list