Actions
Bug #13775
closedRuby hangs when calling scope and belongs_to many times (with mongomapper)
Description
Following code will hang Ruby:
require 'bundler/setup'
require 'mongo_mapper'
MongoMapper.setup(
{
'development' => {
'host' => 'mongo', 'port' => 27017, 'database' => 'db'
}
},
'development'
)
class A
include MongoMapper::Document
10000.times do |i|
scope :"scope_#{i}", order(:"order_#{i}")
belongs_to :"col_#{i}"
end
end
I confirmed that it will happen 2.4.1 and trunk (ruby 2.5.0dev (2017-07-18 trunk 59362) [x86_64-linux]).
Backtrace:
/vendor/bundle/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/associations/single_association.rb:8: [BUG] rb_gc_mark(): 0x0000000178d240 is T_NONE
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0015 p:---- s:0062 e:000061 CFUNC :module_eval
c:0014 p:0125 s:0057 e:000056 METHOD /vendor/bundle/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/associations/single_association.rb:8
c:0013 p:0078 s:0052 e:000051 METHOD /vendor/bundle/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/associations/belongs_to_association.rb:21
c:0012 p:0033 s:0047 e:000046 METHOD /vendor/bundle/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/associations.rb:64
c:0011 p:0029 s:0042 e:000041 METHOD /vendor/bundle/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/associations.rb:14
c:0010 p:0013 s:0035 e:000034 BLOCK main.rb:29 [FINISH]
c:0009 p:---- s:0031 e:000030 IFUNC
c:0008 p:---- s:0028 e:000027 CFUNC :upto
c:0007 p:---- s:0025 e:000024 CFUNC :each
c:0006 p:0018 s:0021 e:000020 METHOD /vendor/bundle/gems/activesupport-4.2.9/lib/active_support/core_ext/range/each.rb:7
c:0005 p:0037 s:0016 E:0007e0 CLASS main.rb:28
c:0004 p:0011 s:0013 e:000012 BLOCK main.rb:23 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :times
c:0002 p:0068 s:0006 e:000005 EVAL main.rb:22 [FINISH]
c:0001 p:0000 s:0003 E:001b80 (none) [FINISH]
Steps to reproduce:
git clone https://gist.github.com/dbbf1afabd372aa1269a954911292cfe.git
cd dbbf1afabd372aa1269a954911292cfe
docker-compose run ruby-2-4-1
docker-compose run ruby-trunk
Full backtrace in my gist.
https://gist.github.com/mtsmfm/dbbf1afabd372aa1269a954911292cfe
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0