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

profiler crashes with java.lang.RuntimeException: BUG: refined marker called as method #6038

Closed
ilikeorangutans opened this issue Jan 14, 2020 · 7 comments

Comments

@ilikeorangutans
Copy link
Contributor

Environment

Provide at least:

  • JRuby version: jruby 9.2.9.0 (2.5.7) 2019-10-30 458ad3e OpenJDK 64-Bit Server VM 25.232-b09 on 1.8.0_232-b09 +jit [darwin-x86_64]
  • Operating system and platform Darwin 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • Installed or activated gems: graphql
  • Enabled profiler via profile

Expected Behavior

Not crash.

Actual Behavior

Jruby crashes when loading the graphql gem which uses Refinements.

Full stack trace, excerpt:

java.lang.RuntimeException: BUG: refined marker called as method
        at org.jruby.internal.runtime.methods.RefinedWrapper.call(RefinedWrapper.java:68)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:196)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
        at org.jruby.internal.runtime.methods.ProfilingDynamicMethod.call(ProfilingDynamicMethod.java:54)
        at org.jruby.runtime.callsite.RefinedCachingCallSite.call(RefinedCachingCallSite.java:59)
        at Users.jakob.$_dot_gem.jruby.$2_dot_5_dot_7.gems.graphql_minus_1_dot_9_dot_13.lib.graphql.schema.field.invokeOther16:-@(/Users/jakob/.gem/jruby/2.5.7/gems/graphql-1.9.13/lib/graphql/schema/field.rb:177)
        at Users.jakob.$_dot_gem.jruby.$2_dot_5_dot_7.gems.graphql_minus_1_dot_9_dot_13.lib.graphql.schema.field.RUBY$method$initialize$0(/Users/jakob/.gem/jruby/2.5.7/gems/graphql-1.9.13/lib/graphql/schema/field.rb:177)
        at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:84)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:70)

Reproduce

jruby --profile -e 'module X; refine(String) { def blah; end }; end; using X; "foo".blah'
@headius
Copy link
Member

headius commented Jan 14, 2020

Reproduction is actually a bit simpler; calling the refined name from anywhere is enough to trigger it. Here I use to_s so I don't have to using the refinement, and I'll do the same in an upcoming spec:

jruby --profile -e 'module X; refine(String) { def to_s; super; end }; end; "foo".to_s'

headius added a commit that referenced this issue Jan 14, 2020
@headius headius added this to the JRuby 9.2.10.0 milestone Jan 14, 2020
yaauie added a commit to yaauie/logstash-mixin-ecs_compatibility_support that referenced this issue Apr 28, 2021
includes updated jruby to avoid bug that was frequently encountered
in CI: jruby/jruby#6038
yaauie added a commit to yaauie/logstash-mixin-ecs_compatibility_support that referenced this issue Apr 30, 2021
includes updated jruby to avoid bug that was frequently encountered
in CI: jruby/jruby#6038
yaauie added a commit to logstash-plugins/logstash-mixin-ecs_compatibility_support that referenced this issue May 4, 2021
* ci: bump to last 7.x logstash before core ecs support was added

includes updated jruby to avoid bug that was frequently encountered
in CI: jruby/jruby#6038

* add support for aliases in version-constrained implementations
chadlwilson added a commit to chadlwilson/gocd that referenced this issue Nov 1, 2021
….14.0 and ruby-i18n >= 1.8.8

Not sure if this should stay. There is a secondary problem with JRuby `9.2.9.0` with use of refinements in
certain modes noted at jruby/jruby#6038 This was causing `admin/configuration` tests to fail when using `time_ago_in_words` and then crashing with a nonsensical error rather than the root cause error from the JRuby/i18n problem.

This appears to be fixed in JRuby `9.2.10.0` however this version of JRuby involves RubyGems 3 which has some scripting issues on Windows currently. Groan. Believe refinements in this way shouldn't really be used anywhere we are relying on based on a global search.
chadlwilson added a commit to chadlwilson/gocd that referenced this issue Nov 1, 2021
….14.0 and ruby-i18n >= 1.8.8

Not sure if this should stay. There is a secondary problem with JRuby `9.2.9.0` with use of refinements in
certain modes noted at jruby/jruby#6038 This was causing `admin/configuration` tests to fail when using `time_ago_in_words` and then crashing with a nonsensical error rather than the root cause error from the JRuby/i18n problem.

This appears to be fixed in JRuby `9.2.10.0` however this version of JRuby involves RubyGems 3 which has some scripting issues on Windows currently. Groan. Believe refinements in this way shouldn't really be used anywhere we are relying on based on a global search.
@rajaravivarma-r
Copy link

Not sure if using a closed issue is considered a good practice, but I'm commenting it here as the problem seems similar.

Setting `JRUBY_OPTS="--profile.api", and running the spec files throws the following error.

This is the refinement in activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb

using Module.new {
  refine Array do
    alias :orig_sum :sum
  end
}

This is the relevant backtrace,

jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:318:in `sum'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:78:in `sum'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:320:in `sum'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:706:in `sequence_name_from_parts'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:677:in `new_column_from_field'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:118:in `block in columns'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:117:in `map'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:117:in `columns'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:117:in `block in columns'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:116:in `fetch'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:116:in `columns'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:125:in `block in columns_hash'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:124:in `fetch'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:124:in `columns_hash'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:580:in `load_schema!'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/attributes.rb:264:in `load_schema!'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/encryption/encryptable_record.rb:122:in `load_schema!'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:566:in `block in load_schema'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:563:in `synchronize'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:563:in `load_schema'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:429:in `attribute_types'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/inheritance.rb:60:in `new'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator/new_constructor.rb:9:in `new'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:14:in `send'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/configuration.rb:23:in `block in initialize'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `build_class_instance'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:13:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:10:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy/build.rb:9:in `result'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/notifications.rb:208:in `instrument'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:42:in `method_missing'
./spec/fixtures/factories/utils/logger.rb:3:in `block in <main>'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute/dynamic.rb:16:in `block in instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute/dynamic.rb:16:in `block in to_proc'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:75:in `block in instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:75:in `block in define_attribute'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator/invocation_tracker.rb:11:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:14:in `send'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:14:in `send'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
./spec/fixtures/factories/utils/logger.rb:7:in `block in <main>'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `build_class_instance'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:13:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:10:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy/build.rb:9:in `result'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/notifications.rb:208:in `instrument'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:42:in `method_missing'
./spec/fixtures/factories/utils/http_req.rb:4:in `block in <main>'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute/dynamic.rb:16:in `block in instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute/dynamic.rb:16:in `block in to_proc'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:75:in `block in instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:75:in `block in define_attribute'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator/invocation_tracker.rb:11:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:14:in `send'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:14:in `send'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/decorator.rb:10:in `method_missing'
./spec/fixtures/factories/utils/http_req.rb:10:in `block in <main>'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `instance_exec'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:51:in `build_class_instance'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/attribute_assigner.rb:13:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:10:in `object'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy/build.rb:9:in `result'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/notifications.rb:208:in `instrument'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
jruby-9.4.6.0/lib/ruby/gems/shared/gems/factory_bot-6.4.6/lib/factory_bot/evaluator.rb:42:in `method_missing'

@headius
Copy link
Member

headius commented Jun 5, 2024

@rajaravivarma-r More information is never wrong, it just might be the wrong place 😀

Your trace appears to have cut off the actual error message, so it's hard for me to tell if it's the same issue or not. If the error message is the same, please add it to your trace. If it is different, I think you should open a new bug.

@rajaravivarma-r
Copy link

@headius Apologies for not posting the actual error message. I'll make a minimal reproducible example and post it here.

@rajaravivarma-r
Copy link

@headius Here is the error with full backtrace of the spec.

     NoMethodError:
       undefined method `orig_sum' for [10, 2, 3]:Array
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:318:in `sum'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:78:in `sum'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activesupport-7.0.8/lib/active_support/core_ext/enumerable.rb:320:in `sum'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:706:in `sequence_name_from_parts'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:677:in `new_column_from_field'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:118:in `block in columns'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:117:in `map'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:117:in `columns'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:117:in `block in columns'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:116:in `fetch'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:116:in `columns'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:125:in `block in columns_hash'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:124:in `fetch'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/connection_adapters/schema_cache.rb:124:in `columns_hash'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:580:in `load_schema!'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/attributes.rb:264:in `load_schema!'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/encryption/encryptable_record.rb:122:in `load_schema!'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:566:in `block in load_schema'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:563:in `synchronize'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:563:in `load_schema'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:429:in `attribute_types'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/activerecord-7.0.8/lib/active_record/inheritance.rb:60:in `new'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:60:in `block in subject'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:179:in `block in fetch_or_store'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:179:in `block in fetch'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:179:in `block in fetch_or_store'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-support-3.13.1/lib/rspec/support/reentrant_mutex.rb:25:in `synchronize'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:178:in `block in fetch_or_store'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch_or_store'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:58:in `subject'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/memoized_helpers.rb:82:in `should'
     # ./spec/models/async_job_spec.rb:5:in `block in <main>'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263:in `block in instance_exec'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263:in `block in run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:511:in `block in with_around_and_singleton_context_hooks'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:468:in `block in with_around_example_hooks'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:486:in `block in run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:352:in `call'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-rails-6.1.2/lib/rspec/rails/adapters.rb:75:in `block in MinitestLifecycleAdapter'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:457:in `instance_exec'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:457:in `instance_exec'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:628:in `block in run_around_example_hooks_for'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:352:in `call'
     # ./spec/support/database_cleaner_setup.rb:11:in `block in <main>'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:30:in `cleaning'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/stdlib/forwardable.rb:238:in `cleaning'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in `block in cleaning'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in `cleaning'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/stdlib/forwardable.rb:238:in `cleaning'
     # ./spec/support/database_cleaner_setup.rb:10:in `block in <main>'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:457:in `instance_exec'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:457:in `instance_exec'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:390:in `execute_with'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:628:in `block in run_around_example_hooks_for'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:352:in `call'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/hooks.rb:486:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:468:in `with_around_example_hooks'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:259:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:646:in `block in run_examples'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:651:in `map'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:651:in `run_examples'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:607:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:608:in `block in run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:608:in `map'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/example_group.rb:608:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:121:in `block in run_specs'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:121:in `block in map'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:121:in `block in run_specs'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/configuration.rb:2091:in `with_suite_hooks'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:116:in `block in run_specs'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/reporter.rb:74:in `report'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:115:in `run_specs'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:89:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:71:in `run'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/lib/rspec/core/runner.rb:45:in `invoke'
     # /Users/rajaravivarma/.asdf/installs/ruby/jruby-9.4.6.0/lib/ruby/gems/shared/gems/rspec-core-3.13.0/exe/rspec:4:in `<main>'
     # bin/rspec:27:in `load'
     # bin/rspec:27:in `<main>'

The expectation that triggered the error,

  1) AsyncJob associations
     Failure/Error: it { should belong_to(:item) }

async_job.rb

class AsyncJob < ApplicationRecord
  belongs_to :item
end

async_job_spec.rb

require 'rails_helper'

RSpec.describe AsyncJob, type: :model do
  describe 'associations' do
    it { should belong_to(:item) }
  end
end
end

Please let me know if you need more details.

Please feel free to ignore my attempt at producing a minimal example with the following code - it just works fine.

minimal_example.rb

using Module.new {
  refine Array do
    alias :orig_sum :sum
  end
}

class Array # :nodoc:
  def sum(init = nil, &block)
    if init.is_a?(Numeric) || first.is_a?(Numeric)
      init ||= 0
      orig_sum(init, &block)
    else
      super
    end
  end
end

def main
  a = [1, 2, 3, 4, 5]
  puts a.sum
  puts a.orig_sum
end

main

@headius
Copy link
Member

headius commented Jun 11, 2024

Are you able to reproduce using your minimal example on JRuby 9.4.7.0? I could not with this simple command line:

$ jruby --profile blah.rb
Profiling enabled; ^C shutdown will now dump profile info
15
15

main profile results:
Total time: 0.66

     total        self    children       calls  method
----------------------------------------------------------------
      0.65        0.06        0.59          18  Kernel.load
      0.56        0.11        0.46          22  Kernel.require
      0.24        0.00        0.24         171  Array#each
      0.23        0.00        0.23           1  Gem::Specification.load_defaults
...

@rajaravivarma-r
Copy link

@headius My message was not clear. I could not reproduce the error using the minimal example.

I did more digging and found that it happens only when using rspec. The same code works fine without rspec. I'll report back once I do some more digging.

Thanks for checking this out.

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

No branches or pull requests

3 participants