From 5e5f2a6de17681f03075b0b83e889581661a561a Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 21 Jan 2026 11:59:08 +0900 Subject: [PATCH 1/3] Setup test with ASAN --- .github/workflows/ruby.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 30cead014..ff4dab374 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -32,6 +32,8 @@ jobs: job: rubocop validate test_doc build test_generate_stdlib raap - ruby: "4.0" job: typecheck_test + - ruby: asan-release + job: test env: RANDOMIZE_STDLIB_TEST_ORDER: "true" steps: @@ -66,6 +68,10 @@ jobs: - name: bin/setup run: | bin/setup + - name: Configure ASAN options + if: ${{ contains(matrix.ruby, 'asan') }} + run: | + echo "ASAN_OPTIONS=abort_on_error=1" >> $GITHUB_ENV - name: Run test run: | bundle exec rake ${{ matrix.job }} From 951e57dc21ae17c9e22b16f193f91a7199ed9c10 Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 21 Jan 2026 11:59:38 +0900 Subject: [PATCH 2/3] Try asan --- ext/rbs_extension/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/rbs_extension/main.c b/ext/rbs_extension/main.c index 7f21237d2..41219930f 100644 --- a/ext/rbs_extension/main.c +++ b/ext/rbs_extension/main.c @@ -466,6 +466,10 @@ void Init_rbs_extension(void) { #ifdef HAVE_RB_EXT_RACTOR_SAFE rb_ext_ractor_safe(true); #endif + // ASAN test: intentional heap buffer overflow to verify ASAN is working + volatile char *test_ptr = malloc(10); + test_ptr[10] = 'A'; // Out of bounds write - this will be caught by ASAN + rbs__init_constants(); rbs__init_location(); rbs__init_parser(); From 5fe342c7b7e2776c8edf6773bbae137deaffa510 Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 21 Jan 2026 12:04:25 +0900 Subject: [PATCH 3/3] Revert code that fails with ASAN --- ext/rbs_extension/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ext/rbs_extension/main.c b/ext/rbs_extension/main.c index 41219930f..7f21237d2 100644 --- a/ext/rbs_extension/main.c +++ b/ext/rbs_extension/main.c @@ -466,10 +466,6 @@ void Init_rbs_extension(void) { #ifdef HAVE_RB_EXT_RACTOR_SAFE rb_ext_ractor_safe(true); #endif - // ASAN test: intentional heap buffer overflow to verify ASAN is working - volatile char *test_ptr = malloc(10); - test_ptr[10] = 'A'; // Out of bounds write - this will be caught by ASAN - rbs__init_constants(); rbs__init_location(); rbs__init_parser();