New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent `Marshal.load` from looping infinitely #24150

Merged
merged 1 commit into from Mar 11, 2016

Conversation

Projects
None yet
6 participants
@exviva
Contributor

exviva commented Mar 11, 2016

Fix a bug in Marshal.load that caused it to loop indefinitely when
trying to autoload a constant that resolved to a different name.

This could occur when marshalling an ActiveRecord 4.0 object (e.g. into
memcached) and then trying to unmarshal it with Rails 4.2. The
marshalled payload contains a reference to
ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column, which in
Rails 4.2 resolves to
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column.

Prevent `Marshal.load` from looping infinitely
Fix a bug in `Marshal.load` that caused it to loop indefinitely when
trying to autoload a constant that resolved to a different name.

This could occur when marshalling an ActiveRecord 4.0 object (e.g. into
memcached) and then trying to unmarshal it with Rails 4.2. The
marshalled payload contains a reference to
`ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column`, which in
Rails 4.2 resolves to
`ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column`.
@rails-bot

This comment has been minimized.

rails-bot commented Mar 11, 2016

r? @pixeltrix

(@rails-bot has picked a reviewer for you, use r? to override)

@exviva exviva force-pushed the exviva:unmarshal-infinite-retry branch to aa0fad5 Mar 11, 2016

@rafaelfranca

This comment has been minimized.

Member

rafaelfranca commented Mar 11, 2016

@fxn what do you think? To me it makes sense but I'm asking since you have more knowledge about our constant resolving behavior.

@fxn

This comment has been minimized.

Member

fxn commented Mar 11, 2016

Looking good!

fxn added a commit that referenced this pull request Mar 11, 2016

Merge pull request #24150 from exviva/unmarshal-infinite-retry
Prevent `Marshal.load` from looping infinitely

@fxn fxn merged commit e56b594 into rails:master Mar 11, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@exviva exviva deleted the exviva:unmarshal-infinite-retry branch Mar 11, 2016

@exviva

This comment has been minimized.

Contributor

exviva commented Mar 11, 2016

Thanks for merging @fxn! Can we also backport to 4-2-stable? #24157

rafaelfranca pushed a commit that referenced this pull request Mar 11, 2016

Prevent `Marshal.load` from looping infinitely
Fix a bug in `Marshal.load` that caused it to loop indefinitely when
trying to autoload a constant that resolved to a different name.

This could occur when marshalling an ActiveRecord 4.0 object (e.g. into
memcached) and then trying to unmarshal it with Rails 4.2. The
marshalled payload contains a reference to
`ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column`, which in
Rails 4.2 resolves to
`ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column`.

This backports #24150 to 4-2-stable

mtsmfm added a commit to mtsmfm/rails that referenced this pull request Mar 28, 2016

Fix marshal with autoloading for nested class/module
rails#24150 break autoloading for nested class/module.

There is test for nested class but it doesn't work correctly.
Following code will autoload `ClassFolder::ClassFolderSubclass` before `Marshal.load`:

`assert_kind_of ClassFolder::ClassFolderSubclass, Marshal.load(dumped)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment