Skip to content

Chrome debugger crashes #781

Closed
Closed

Description

@richardkmichael

Your environment

  • ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin20]
  • rdbg -v: rdbg 1.6.3

Describe the bug

While stepping through active_record code using the Chrome devtools debugger, the debugger seems to have accessed a property index which is nil, causing the debugger to crash.

The debugger does not crash if not using Chrome devtools. (Unsurprising, since the nil value appears to be in the server/threading code.)

To Reproduce

Other than trying to step through the code, I am unsure how to reproduce it.

I stepped through many times, and it always crashed at the same place, inside i18n fallback.rb code.

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  ruby "3.1.2", patchlevel: "20"

  gem "debug", "1.6.3"
  gem "sqlite3", "1.5.3"
  gem "activerecord", "7.0.4"
end

require "active_record"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "data")

class Person < ActiveRecord::Base ; end

# Debugger will crash on fallbacks.rb:20, so set a break point on line 19 to make re-pro easier.
# In the Chrome devtools, no breakpoints are shown, but the break point is in fact set.
# Use the "Resume script execution" button, or `F8`, to stop at the break point, then step-in once more to crash at i18n fallback.rb:20

debugger

# break vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/fallbacks.rb:19
# open chrome

Person.first

Expected behavior

Continue stepping without crashing.

Additional context

Backtrace:

(rdbg) break vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/fallbacks.rb:19    # command
(rdbg) open chrome    # command
DEBUGGER: wait for debugger connection...
DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:49906)
DEBUGGER: Connected.

["DEBUGGER Exception: dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:1108",
 #<NoMethodError: undefined method `[]=' for nil:NilClass

            pd[:value][:preview][:properties][idx][:valuePreview] = valuePreview
                                                  ^^^^^^^^^^^^^^^^^>,
 ["dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:1085:in `block in variable'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:1082:in `each'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:1082:in `each_with_index'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:1082:in `variable'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:940:in `block in process_cdp'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:539:in `block in special_local_variables'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:536:in `each'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:536:in `special_local_variables'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/server_cdp.rb:939:in `process_cdp'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:1099:in `wait_next_action_'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:797:in `wait_next_action'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:310:in `suspend'",
  "dir/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/thread_client.rb:344:in `block in step_tp'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/fallbacks.rb:20:in `fallbacks'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/inflector/inflections.rb:68:in `instance_or_fallback'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/inflector/inflections.rb:267:in `inflections'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/inflector/methods.rb:99:in `underscore'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/naming.rb:218:in `_singularize'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/naming.rb:173:in `initialize'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/naming.rb:264:in `new'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/naming.rb:264:in `model_name'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/model_schema.rb:630:in `compute_table_name'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/model_schema.rb:284:in `reset_table_name'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/model_schema.rb:248:in `table_name'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/core.rb:421:in `arel_table'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation.rb:27:in `initialize'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/delegation.rb:118:in `new'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/delegation.rb:118:in `create'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/core.rb:439:in `relation'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/scoping/named.rb:45:in `default_scoped'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/scoping/named.rb:32:in `all'",
  "dir/proj/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/querying.rb:22:in `first'",
  "main.rb:9:in `<main>'"]]
DEBUGGER: Disconnected.

Activity

  1. added a commit that references this issue on Nov 3, 2022
    a7da375
  2. ono-max commented on Nov 3, 2022

    @ono-max
    Member

    Thank you for reporting the issue. It's easy to reproduce the bug because your description is well-written.

  3. added a commit that references this issue on Sep 2, 2024
    607a1c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions