[ruby-core:116815] [Ruby master Feature#20274] Add RubyVM::ASAN.enabled?

Issue #20274 has been reported by kjtsanaktsidis (KJ Tsanaktsidis). ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by kjtsanaktsidis (KJ Tsanaktsidis). The other option is to define `RubyVM.asan_enabled?` as a method, rather than defining `RubyVM::ASAN` as a module. ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106839 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by nobu (Nobuyoshi Nakada). At first, ASAN is not related to Ruby VM, neither the constant nor method under `RubyVM` do not make sense. How are you going to detect it? Maybe from CFLAGS? ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106840 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by kjtsanaktsidis (KJ Tsanaktsidis). GCC & clang set macros indicating that asan is enabled: https://github.com/ruby/ruby/blob/df63e5bef67ff74216834f61748aa6ea8b0de22e/i... So I was going to implement `RubyVM::ASAN.enabled?` by using conditional compilation to just return Qtrue or Qfalse. Maybe `RbConfig` might be a better place for it? I think I’d have to write some autoconf macros/test program to emit an AC_SUBST about whether asan is enabled. But that should be just as robust. WDYT? ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106847 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by mame (Yusuke Endoh). You just need the API for the Ruby test suite, right? Then, it would be enough to implement it in ext/-test-/. Introducing a method under RubyVM means making it available to Ruby users. Is that necessary? Note, I don't think that it is a good idea to change the test behavior only when ASAN is enabled. I understand #20273 since callcc is very special, though. ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106851 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by kjtsanaktsidis (KJ Tsanaktsidis).
Then, it would be enough to implement it in ext/-test-/.
This is a much better idea - I'll do this.
Note, I don't think that it is a good idea to change the test behavior only when ASAN is enabled
I definitely agree with this in general. The only place I've found so far where I actually want to change test behaviour on ASAN is `assert_no_memory_leak` which I think is also a bit special (it just hardcodes some guess numbers about how much memory the subprocess "should" use. I'm very carefully evaluating all the other failures the test suite throws up and fixing them :) (I think I have found two actual real bugs already with it!) ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106858 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open * Priority: Normal ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/

Issue #20274 has been updated by kjtsanaktsidis (KJ Tsanaktsidis). I opened https://github.com/ruby/ruby/pull/10087 to implement this as an extension in `ext/-test-/` as suggested. ---------------------------------------- Feature #20274: Add RubyVM::ASAN.enabled? https://bugs.ruby-lang.org/issues/20274#change-106960 * Author: kjtsanaktsidis (KJ Tsanaktsidis) * Status: Open ---------------------------------------- Some parts of the Ruby test suite won't work correctly under ASAN. In particular, `assert_no_memory_leak` will need different parameters for ASAN (or be skipped, in the same way as for MJIT/RJIT). I propose that we add a module `RubyVM::ASAN` (which will be unconditionally defined), and `RubyVM::ASAN.enabled?` (which will return true if Ruby was compiled with ASAN, or false otherwise). This means we can check if ASAN is enabled by running `defined?(RubyVM::ASAN) && RubyVM::ASAN.enabled?`, in the same way that the mjit/rjit check is performed. -- https://bugs.ruby-lang.org/
participants (3)
-
kjtsanaktsidis (KJ Tsanaktsidis)
-
mame (Yusuke Endoh)
-
nobu (Nobuyoshi Nakada)