Project

General

Profile

Actions

Bug #20221

closed

ASAN: make test-basic: un-prefixed symbol leakage

Added by leeN (David Klein) 3 months ago. Updated 3 months ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-01-29T08:16:49Z master 8bff7e996c)
[ruby-core:116473]

Description

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:

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.


Related issues 1 (1 open0 closed)

Related to Ruby master - Misc #20387: Meta-ticket for ASAN supportAssignedkjtsanaktsidis (KJ Tsanaktsidis)Actions

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

  • 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!

Actions #2

Updated by Anonymous 3 months ago

  • Status changed from Open to Closed

Applied in changeset git|565ef06e917c6f326f8d528dc8fa6c6de88a8753.


Ignore _odr_asan symbols in leaked-globals

ASAN includes these to detect violations of the ODR rule.

[Bug #20221]

Actions #3

Updated by kjtsanaktsidis (KJ Tsanaktsidis) about 2 months ago

  • Related to Misc #20387: Meta-ticket for ASAN support added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0