Skip to content
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

Incompatibility with Padrino framework #1067

Closed
francesmcmullin opened this issue Oct 16, 2024 · 2 comments · Fixed by #1068
Closed

Incompatibility with Padrino framework #1067

francesmcmullin opened this issue Oct 16, 2024 · 2 comments · Fixed by #1068

Comments

@francesmcmullin
Copy link
Contributor

There is a rare incompatibility between concurrent ruby and the Padrino framework. Padrino monkey patches the Kernel object to support logging in any context, and this causes an error when initializing a concurrent class such as Concurrent::MutableStruct::ThreadSafeConfig. The error occurs here:

clazz.send :remove_method, member if clazz.instance_methods.include? member

The method logger returns true for clazz.instance_methods.include? member because it is present on Object (via the parent, Kernel), but attempting clazz.send :remove_method, :logger throws an error because the method is not present on the class itself. It seems as though using the optional argument to instance_methods to scope down to only methods present on this object (not ancestors) might resolve the issue. That would give us something like clazz.instance_methods(false).include? member .

Stack trace:

NameError: method `logger' not defined in Concurrent::MutableStruct::ThreadSafeConfig
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb:160:in `remove_method'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb:160:in `block in define_struct_class'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb:159:in `each'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb:159:in `each_with_index'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb:159:in `define_struct_class'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb:223:in `block in define_struct'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb:222:in `define_struct'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/mutable_struct.rb:217:in `new'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/sidekiq-unique-jobs-8.0.10/lib/sidekiq_unique_jobs/config.rb:5:in `<module:SidekiqUniqueJobs>'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/sidekiq-unique-jobs-8.0.10/lib/sidekiq_unique_jobs/config.rb:3:in `<top (required)>'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/sidekiq-unique-jobs-8.0.10/lib/sidekiq_unique_jobs.rb:79:in `<top (required)>'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/sidekiq-unique-jobs-8.0.10/lib/sidekiq-unique-jobs.rb:3:in `<top (required)>'
<internal:/usr/local/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/usr/local/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/runtime.rb:55:in `each'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/runtime.rb:55:in `block in require'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/runtime.rb:44:in `each'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/runtime.rb:44:in `require'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler.rb:212:in `require'
/home/circleci/project/config/boot.rb:12:in `<top (required)>'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/padrino-core-0.16.0.pre3/lib/padrino-core/cli/rake_tasks.rb:15:in `block in <top (required)>'
/home/circleci/project/vendor/bundle/ruby/3.3.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli/exec.rb:58:in `load'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli/exec.rb:23:in `run'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli.rb:455:in `exec'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli.rb:35:in `dispatch'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/cli.rb:29:in `start'
/home/circleci/.rubygems/gems/bundler-2.5.21/exe/bundle:28:in `block in <top (required)>'
/home/circleci/.rubygems/gems/bundler-2.5.21/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/home/circleci/.rubygems/gems/bundler-2.5.21/exe/bundle:20:in `<top (required)>'
/home/circleci/.rubygems/bin/bundle:25:in `load'
/home/circleci/.rubygems/bin/bundle:25:in `<main>'
* Operating system:                linux / mac
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1.3.4
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:    no
@eregon
Copy link
Collaborator

eregon commented Oct 16, 2024

Right, that makes sense, please open a PR with that and a spec.

@francesmcmullin
Copy link
Contributor Author

Right, that makes sense, please open a PR with that and a spec.

Thanks for the quick response! I've added a PR now

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

Successfully merging a pull request may close this issue.

2 participants