Bug #11658
closedSegmentation fault with activeadmin test suite
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
Updated by normalperson (Eric Wong) over 8 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) over 8 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) over 8 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) over 8 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) over 8 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
<top (required)>'
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) over 8 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) over 8 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) over 8 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) over 8 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.
Updated by Anonymous over 8 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) over 8 years ago
Thanks all. Committed my 3-liner and h.shirosaki's test as r52511