#840 ✓resolved
Ashley Moran

Defining a property called 'model' causes a stack overflow

Reported by Ashley Moran | April 25th, 2009 @ 01:36 PM | in 1.0.0

The following code:


require 'rubygems'
require 'datamapper'

DataMapper.setup(:default, :adapter => 'in_memory')

class RecursiveFail
  include DataMapper::Resource
  
  property :id,     Serial
  property :model,  String
end

r = RecursiveFail.new(:model => "test")
puts r.model

produces the following stack trace:


/opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get': stack level too deep (SystemStackError)
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
	 ... 4368 levels...
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:615:in `assert_valid_model'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:609:in `initialize'
	from recursive_property_name.rb:13:in `new'
	from recursive_property_name.rb:13

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages