Project

General

Profile

Actions

Bug #11658

closed

Segmentation fault with activeadmin test suite

Added by hsbt (Hiroshi SHIBATA) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-11-04 trunk 52452) [x86_64-darwin15]
[ruby-core:71345]

Description

I detect causes of SEGV with Ruby 2.3.0 HEAD and activeadmin-1.0.0.pre2 after r52332.

Please try following instructions with ruby of r52332.

$ gem install bundler
$ git clone --branch v1.0.0.pre2 https://github.com/activeadmin/activeadmin
$ cd activeadmin
$ bundle exec rspec spec/unit/active_admin_spec.rb

this segv is happened at launching rails server too. I attached crash log.

Please investigate this.


Files

ruby_2015-11-05-115449_osx.crash (19.2 KB) ruby_2015-11-05-115449_osx.crash hsbt (Hiroshi SHIBATA), 11/05/2015 03:37 AM

Updated by normalperson (Eric Wong) about 6 years ago

Anyway to reproduce this without loading a JS engine?
I haven't touched anything Rails-related in years because of JS.

Updated by hsbt (Hiroshi SHIBATA) about 6 years ago

Anyway to reproduce this without loading a JS engine?

Yes, I can reproduce with ruby -Ilib:spec -e "require 'rails_helper'" in activeadmin directory.

Updated by normalperson (Eric Wong) about 6 years ago

It's still asking for a JS runtime:

/lib/ruby/gems/2.3.0/gems/execjs-2.4.0/lib/execjs/runtimes.rb:45:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes

Sorry I can't trust JS to run.
Do you have standalone Ruby code to reproduce the issue?
Also, does this error happen on GNU/Linux systems with NPTL?
Maybe it is a platform-dependent threading bug.

Updated by hsbt (Hiroshi SHIBATA) about 6 years ago

  • Status changed from Open to Assigned

Can you install nodejs via apt?

I got another error related with r52332 at ubuntu 14.04

$ sudo apt install nodejs
$ cd activeadmin
$ bundle exec rake spec
(snip)
/data/dev/activeadmin/lib/active_admin/resource/action_items.rb:5:in `<module:ActiveAdmin>': No live threads left. Deadlock? (fatal)
    from /data/dev/activeadmin/lib/active_admin/resource/action_items.rb:3:in `<top (required)>'

above error happend by "ruby 2.3.0dev (2015-11-05 trunk 52458) [x86_64-linux]"

it works with Ruby 2.2.0(ruby 2.2.4p185 (2015-11-01 revision 52414) [x86_64-linux])

Updated by normalperson (Eric Wong) about 6 years ago

shibata.hiroshi@gmail.com wrote:

Can you install nodejs via apt?

Sorry, I'm willing to audit all that code before I run it.
I cannot afford to develop any expectation of being able to
run/debug JS in any way; likewise for X11/GNOME or worse things.

$ sudo apt install nodejs
$ cd activeadmin
$ bundle exec rake spec
(snip)
/data/dev/activeadmin/lib/active_admin/resource/action_items.rb:5:in <module:ActiveAdmin>': No live threads left. Deadlock? (fatal)
from /data/dev/activeadmin/lib/active_admin/resource/action_items.rb:3:in
'

Maybe this three-line patch fixes the deadlock recursion problem:

http://80x24.org/spew/20151105213303.19743-1-e%4080x24.org/raw

No successful standalone reproduction, yet:

http://80x24.org/spew/20151105220751.24371-1-e%4080x24.org/raw

As stated in https://bugs.ruby-lang.org/issues/11384 ,
I was not comfortable with the original patch; so maybe
reverting the series is better if we cannot solve it right away;
especially since I don't consider the additional locking a complete
fix in [ruby-core:71305]

http://80x24.org/spew/20151105212409.23859-1-e%4080x24.org/raw
(reverts r52446, r52335, r52332)

Updated by hsbt (Hiroshi SHIBATA) about 6 years ago

Maybe this three-line patch fixes the deadlock recursion problem:

http://80x24.org/spew/20151105213303.19743-1-e%4080x24.org/raw

I confirmed to works r52461 with this patch at activeadmin-1.0.0.pre2 tests.

Updated by normalperson (Eric Wong) about 6 years ago

shibata.hiroshi@gmail.com wrote:

Maybe this three-line patch fixes the deadlock recursion problem:

http://80x24.org/spew/20151105213303.19743-1-e%4080x24.org/raw

I confirmed r52461 with this patch at activeadmin-1.0.0.pre2 tests.

Thanks, now we need to figure out a test case for this...

Updated by h.shirosaki (Hiroshi Shirosaki) about 6 years ago

I found a test that causes deadlock.

diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index 719502d..a672e0b 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -215,6 +215,25 @@ p Foo::Bar
     end
   end

+  def test_autoload_while_autoloading
+    ruby_impl_require do |called_with|
+      Tempfile.create(%w(a .rb)) do |a|
+        Tempfile.create(%w(b .rb)) do |b|
+          a.puts "require '#{b.path}'; class AutoloadTest; end"
+          b.puts "class AutoloadTest; module B; end; end"
+          [a, b].each(&:flush)
+          add_autoload(a.path)
+          begin
+            assert(Object::AutoloadTest)
+          ensure
+            remove_autoload_constant
+          end
+          assert_equal [a.path, b.path], called_with
+        end
+      end
+    end
+  end
+
   def add_autoload(path)
     (@autoload_paths ||= []) << path
     ::Object.class_eval {autoload(:AutoloadTest, path)}

Updated by deivid (David Rodríguez) about 6 years ago

I confirmed on my system.

  • The proposed test deadlocks.
  • The proposed 3 line patch makes the test pass.
  • The proposed 3 line patch resolves activeadmin's deadlock issue.
Actions #10

Updated by Anonymous about 6 years ago

  • Status changed from Assigned to Closed

Applied in changeset r52511.


variable.c (rb_autoload_load): allow recursive calls

  • variable.c (rb_autoload_load): allow recursive calls [ruby-core:71345] [Bug #11658]
  • test/ruby/test_autoload.rb (test_autoload_while_autoloading): new test by: Hiroshi Shirosaki h.shirosaki@gmail.com [ruby-core:71390]

Updated by normalperson (Eric Wong) about 6 years ago

Thanks all. Committed my 3-liner and h.shirosaki's test as r52511

Actions

Also available in: Atom PDF