[ruby-core:116473] [Ruby master Bug#20221] ASAN: make test-basic: un-prefixed symbol leakage

Issue #20221 has been reported by leeN (David Klein). ---------------------------------------- Bug #20221: ASAN: make test-basic: un-prefixed symbol leakage https://bugs.ruby-lang.org/issues/20221 * Author: leeN (David Klein) * Status: Open * Priority: Normal * ruby -v: ruby 3.4.0dev (2024-01-29T08:16:49Z master 8bff7e996c) * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When building and running the tests (here, test-basic) with ASAN enabled, it fails with the following message: ``` Checking leaked global symbols...leaked __odr_asan_gen_rb_cArray __odr_asan_gen_ruby_digitmap __odr_asan_gen_rb_mComparable ...snip... __odr_asan_gen_OnigEncodingASCII __odr_asan_gen_OnigEncodingUS_ASCII __odr_asan_gen_OnigEncodingUTF_8 232 un-prefixed symbols leaked ``` To reproduce: ``` shell git checkout master mkdir build && cd build CXX=clang++ CC=clang ../configure cppflags="-fsanitize=address -fno-omit-frame-pointer" optflags=-O0 LDFLAGS="-fsanitize=address -fno-omit-frame-pointer" ASAN_OPTIONS=use_sigaltstack=0:detect_leaks=0:abort_on_error=1 make ASAN_OPTIONS=use_sigaltstack=0:detect_leaks=0:abort_on_error=1 make test-basic ``` To fix: ``` diff --git a/tool/leaked-globals b/tool/leaked-globals index ee75f78d1d..9e78228274 100755 --- a/tool/leaked-globals +++ b/tool/leaked-globals @@ -79,6 +79,7 @@ next unless n.sub!(/^#{SYMBOL_PREFIX}/o, "") next if n.include?(".") next if !so and n.start_with?("___asan_") + next if n.start_with?("__odr_asan") case n when /\A(?:Init_|InitVM_|pm_|[Oo]nig|dln_|coroutine_)/ next ``` I'm not overly familiar with Ruby, so this might not be the preferred approach, but it made the issue go away for me. -- https://bugs.ruby-lang.org/

Issue #20221 has been updated by kjtsanaktsidis (KJ Tsanaktsidis). Assignee set to kjtsanaktsidis (KJ Tsanaktsidis) Thanks for this. I'm able to reproduce this on my machine (Fedora 39 with clang 17.0.6). A cursory inspection suggests this might be a new behaviour in Clang 17, because of `-fsanitize-address-use-odr-indicator` defaulting to on (https://reviews.llvm.org/D137227?id=472507). I'll have a look at fixing this - thanks for your patch, I suspect it may well be the correct thing to do. Can I ask, what are you hoping to achieve by running Ruby through ASAN? There are definitely several bugs in Ruby's implementation of ASAN, and I'm not sure it's really suitable yet for actually finding real issues in Ruby or extension code. For example, I have an open PR https://github.com/ruby/ruby/pull/9734 which a) fixes how M:N threading reports stack switches to ASAN, and b) fixes `ObjectSpace.each_object` (and all functionality which directly or indirectly depends on it) not actuallly scanning all objects. It is definitely my intention to get Ruby's ASAN instrumentation to a point where it's not reporting any false positives, and make it a useful tool for debugging both Ruby itself as well as native extensions. However it's not there yet! ---------------------------------------- Bug #20221: ASAN: make test-basic: un-prefixed symbol leakage https://bugs.ruby-lang.org/issues/20221#change-106494 * Author: leeN (David Klein) * Status: Open * Priority: Normal * Assignee: kjtsanaktsidis (KJ Tsanaktsidis) * ruby -v: ruby 3.4.0dev (2024-01-29T08:16:49Z master 8bff7e996c) * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When building and running the tests (here, test-basic) with ASAN enabled, it fails with the following message: ``` Checking leaked global symbols...leaked __odr_asan_gen_rb_cArray __odr_asan_gen_ruby_digitmap __odr_asan_gen_rb_mComparable ...snip... __odr_asan_gen_OnigEncodingASCII __odr_asan_gen_OnigEncodingUS_ASCII __odr_asan_gen_OnigEncodingUTF_8 232 un-prefixed symbols leaked ``` To reproduce: ``` shell git checkout master mkdir build && cd build CXX=clang++ CC=clang ../configure cppflags="-fsanitize=address -fno-omit-frame-pointer" optflags=-O0 LDFLAGS="-fsanitize=address -fno-omit-frame-pointer" ASAN_OPTIONS=use_sigaltstack=0:detect_leaks=0:abort_on_error=1 make ASAN_OPTIONS=use_sigaltstack=0:detect_leaks=0:abort_on_error=1 make test-basic ``` To fix: ``` diff --git a/tool/leaked-globals b/tool/leaked-globals index ee75f78d1d..9e78228274 100755 --- a/tool/leaked-globals +++ b/tool/leaked-globals @@ -79,6 +79,7 @@ next unless n.sub!(/^#{SYMBOL_PREFIX}/o, "") next if n.include?(".") next if !so and n.start_with?("___asan_") + next if n.start_with?("__odr_asan") case n when /\A(?:Init_|InitVM_|pm_|[Oo]nig|dln_|coroutine_)/ next ``` I'm not overly familiar with Ruby, so this might not be the preferred approach, but it made the issue go away for me. -- https://bugs.ruby-lang.org/
participants (2)
-
kjtsanaktsidis (KJ Tsanaktsidis)
-
leeN (David Klein)