Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

can't modify frozen NilClass #77

Closed
tpitale opened this issue Mar 8, 2015 · 12 comments
Closed

can't modify frozen NilClass #77

tpitale opened this issue Mar 8, 2015 · 12 comments

Comments

@tpitale
Copy link
Member

tpitale commented Mar 8, 2015

Calling empty? on an has n association. Ruby 2.2.0, worked previous versions of ruby.

from bundle/ruby/2.2.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:144:in `track'
from bundle/ruby/2.2.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:161:in `hook_value'
from bundle/ruby/2.2.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:151:in `set!'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:607:in `block (2 levels) in load'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:598:in `each'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:598:in `block in load'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:577:in `map'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:577:in `load'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/repository.rb:162:in `read'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/collection.rb:1118:in `lazy_load'
from bundle/ruby/2.2.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:87:in `empty?'
from (irb):2
from bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
from bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'irb(main):003:0> r.extract_logs.empty?
@tpitale
Copy link
Member Author

tpitale commented Mar 8, 2015

Subsequent calls to exactly the same method work. Always fails the first time.

@tpitale
Copy link
Member Author

tpitale commented Mar 8, 2015

This may be a dm-core issue, and only happens to manifest through dm-types because of the DirtyMinder module misdirection.

@tpitale
Copy link
Member Author

tpitale commented Mar 8, 2015

This appears to be related to #71. Closing.

@tpitale tpitale closed this as completed Mar 8, 2015
@tpitale tpitale reopened this Mar 9, 2015
@tpitale
Copy link
Member Author

tpitale commented Mar 9, 2015

Loading a collection at all, for the first time (as empty? evidently does in dm) where one of the properties is Json, Hash, or Array (the classes extended by hooks for dirtiness tracking) leads to this error. No other collection loading fails in this way. Pretty sure that makes it a dm-types issue.

@tpitale
Copy link
Member Author

tpitale commented Mar 9, 2015

This is fixed by PR #50. But, despite it saying in the release from github that v1.2.2 v1.2.2...master has that PR included, looking at the code for the gem release 1.2.2 it does not have the code from PR #50.

@tpitale tpitale closed this as completed Mar 9, 2015
@robclancy
Copy link

This issue has made me regret use datamapper at all :/

@gregory
Copy link

gregory commented Dec 4, 2015

same here. that's bad.

@julienma
Copy link

julienma commented Mar 4, 2016

Well, same issue.
Had to fork v1.2.2 and cherry pick the 3 commits from #50.

Now, I just have to add this to my Gemfile:

gem 'dm-types',
  :git => 'git://github.com/julienma/dm-types.git',
  :branch => 'gem-v1.2.2-with-frozen-nilclass-fix'

@ZeroChaos-
Copy link

ZeroChaos- commented Jun 30, 2016

kinda looks like this still isn't fixed, is this ever going to be fixed?

2016-06-30T14:17:40.172+0000 ERROR pwnscan#9456: Generic Error: can't
modify frozen NilClass
["/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:144:in
`track'",
"/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:161:in
`hook_value'",
"/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:151:in
`set!'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`block in eager_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`eager_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:865:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/property.rb:664:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource/persistence_state/persisted.rb:23:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource/persistence_state/persisted.rb:8:in
`get'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/model/property.rb:209:in
`attributes_meta'",
"/opt/pwnix/pwnscan/lib/pwnscan/helpers/host_update_helper.rb:21:in
`initialize'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:252:in `new'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:252:in
`update_from_parsed_hash'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:265:in
`mark_offline'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:97:in `block in
deduplicate'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/collection.rb:508:in
`block in each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`block in each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/collection.rb:505:in

@tpitale
Copy link
Member Author

tpitale commented Jun 30, 2016

DM is mostly unmaintained. So, no, probably not getting fixed.

@jcran
Copy link

jcran commented Nov 28, 2016

Ran into this as well, accelerated a project's move off datamapper.

@joshleblanc
Copy link

This can be avoided by turning off lazy loading for the property.

property :some_json, Json, lazy: false

Obviously, you lose the benefits of lazy loading.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants