[compiler-rt] [asan][test] Return success from the Windows CRT initializer (PR #226341)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 19:51:48 PDT 2026


https://github.com/kingakasa created https://github.com/llvm/llvm-project/pull/226341

The test puts call_me_maybe in .CRT$XIB, but declares both the callback and its pointer type as returning void. The CRT's C-initializer sequence expects an int-returning callback, with zero indicating successful initialization.

Change the pointer type and callback to return int, and return zero explicitly. This makes startup independent of an indeterminate return value.

Validation: crt_initializers.cpp passes independently with both dynamic and static CRT configurations. The original test also passes on this baseline; the change corrects the callback contract rather than claiming a newly reproduced failure.

Tested independently on Windows x64 using a fresh Release LLVM/Clang build with assertions enabled and a matching Release ASan runtime, based on `6dc4a4ba2850369afd537001377fb9d404653d26`.

Changed-line clang-format and git diff --check pass.

Assisted-by: OpenAI Codex


>From 241d1420d77ca21876ac09edd49680bd83b79659 Mon Sep 17 00:00:00 2001
From: Kinga Kasa <kasakinga14 at gmail.com>
Date: Thu, 24 Sep 2026 22:50:02 -0400
Subject: [PATCH] [asan][test] Return success from the Windows CRT initializer

The test puts call_me_maybe in .CRT$XIB, but declares both the callback and its pointer type as returning void. The CRT's C-initializer sequence expects an int-returning callback, with zero indicating successful initialization.

Change the pointer type and callback to return int, and return zero explicitly. This makes startup independent of an indeterminate return value.

Validation: crt_initializers.cpp passes independently with both dynamic and static CRT configurations. The original test also passes on this baseline; the change corrects the callback contract rather than claiming a newly reproduced failure.

Tested independently on Windows x64 using a fresh Release LLVM/Clang build with assertions enabled and a matching Release ASan runtime, based on `6dc4a4ba2850369afd537001377fb9d404653d26`.

Changed-line clang-format and git diff --check pass.

Assisted-by: OpenAI Codex
---
 compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp b/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
index 5a1eee33e70111..8e29cfb3ed5a12 100644
--- a/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
@@ -5,7 +5,7 @@
 
 #include <stdio.h>
 
-typedef void (*FPTR)();
+typedef int (*FPTR)();
 
 // __xi_a and __xi_z are defined in VC/crt/src/crt0dat.c
 // and are located in .CRT$XIA and .CRT$XIZ respectively.
@@ -24,7 +24,7 @@ int main() {
 // CHECK: Number of nonzero CRT initializers
 }
 
-void call_me_maybe() {}
+int call_me_maybe() { return 0; }
 
 #pragma data_seg(".CRT$XIB")
 // Add an initializer that shouldn't get its own redzone.



More information about the llvm-commits mailing list