-
Notifications
You must be signed in to change notification settings - Fork 127
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
Unfreeze threads for some object-evaluating commands #1030
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are several commands that evaluate objects and call methods on them, such as: - info - ls (outline) - trace object - display If the called method acquires a mutex shared with another thread (e.g. when using Timeout), then it'd cause a deadlock as all threads are stopped. For example, if there's an ActiveRecord Relation object stored as a local variable, and the user runs the `info` command, then it'd call `inspect` on it and trigger a database query, it could cause a deadlock as described in ruby#877. This commit fixes the issue by unfreezing all threads before evaluating those commands and freezing them again after receiving the result event.
st0012
force-pushed
the
fix-command-freezing-issue
branch
from
October 26, 2023 20:53
8a96c3e
to
c1ec064
Compare
I'm not sure it is safe because current thread management technique does not have enough quality to control them, but try it. |
xjunior
referenced
this pull request
in powerhome/audiences
Dec 11, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [debug](https://togithub.com/ruby/debug) | `1.8.0` -> `1.9.0` | [![age](https://developer.mend.io/api/mc/badges/age/rubygems/debug/1.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/rubygems/debug/1.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/rubygems/debug/1.8.0/1.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/rubygems/debug/1.8.0/1.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ruby/debug (debug)</summary> ### [`v1.9.0`](https://togithub.com/ruby/debug/releases/tag/v1.9.0) [Compare Source](https://togithub.com/ruby/debug/compare/v1.8.0...v1.9.0) #### What's Changed - Configuration - `session_name` config by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1036](https://togithub.com/ruby/debug/pull/1036) - CLI - Require Reline 0.3.8+ to avoid frozen issue by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1020](https://togithub.com/ruby/debug/pull/1020) - Fix prompt list size and colorized code line size to match input line size passed to Reline by [@​tompng](https://togithub.com/tompng) in [https://github.com/ruby/debug/pull/1010](https://togithub.com/ruby/debug/pull/1010) - Fix broken command history when executing debugger on irb by [@​takatea](https://togithub.com/takatea) in [https://github.com/ruby/debug/pull/997](https://togithub.com/ruby/debug/pull/997) - Drop patch for Reline 0.2.7 by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1022](https://togithub.com/ruby/debug/pull/1022) - Support IRB console by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1024](https://togithub.com/ruby/debug/pull/1024) - Remote - Allow TracePoint reentry during DAP's evaluation by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1026](https://togithub.com/ruby/debug/pull/1026) - CDP: Add debuggerId field in the RETURN OBJECT of "Debugger.enable" by [@​ono-max](https://togithub.com/ono-max) in [https://github.com/ruby/debug/pull/1028](https://togithub.com/ruby/debug/pull/1028) - CDP: disable JavaScript engine based autocompletion by [@​ono-max](https://togithub.com/ono-max) in [https://github.com/ruby/debug/pull/1029](https://togithub.com/ruby/debug/pull/1029) - Do not use HEAD request if 1 port by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1035](https://togithub.com/ruby/debug/pull/1035) - Show session_name on connection by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1037](https://togithub.com/ruby/debug/pull/1037) - Internal - Stop assuming Integer#times is written in C by [@​k0kubun](https://togithub.com/k0kubun) in [https://github.com/ruby/debug/pull/1015](https://togithub.com/ruby/debug/pull/1015) - Disable cloned breakpoints trace point events by [@​vinistock](https://togithub.com/vinistock) in [https://github.com/ruby/debug/pull/1008](https://togithub.com/ruby/debug/pull/1008) - Unfreeze threads for some object-evaluating commands by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1030](https://togithub.com/ruby/debug/pull/1030) - Prevent backtrace from hanging if objects in the backtrace use Thread in inspect by [@​vinistock](https://togithub.com/vinistock) in [https://github.com/ruby/debug/pull/1038](https://togithub.com/ruby/debug/pull/1038) - Compile iseq_collector.c logic only on CRuby by [@​eregon](https://togithub.com/eregon) in [https://github.com/ruby/debug/pull/1039](https://togithub.com/ruby/debug/pull/1039) - Fix compatibility with Fiber Scheduler. by [@​ioquatix](https://togithub.com/ioquatix) in [https://github.com/ruby/debug/pull/987](https://togithub.com/ruby/debug/pull/987) - Do not make a Fiber for commands by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1044](https://togithub.com/ruby/debug/pull/1044) - support Ruby 3.3 by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1045](https://togithub.com/ruby/debug/pull/1045) - Misc/Doc - Fix ruby warnings by [@​y-yagi](https://togithub.com/y-yagi) in [https://github.com/ruby/debug/pull/993](https://togithub.com/ruby/debug/pull/993) - Fix a typo by [@​makenowjust](https://togithub.com/makenowjust) in [https://github.com/ruby/debug/pull/988](https://togithub.com/ruby/debug/pull/988) - Update `TrapInterceptor` to avoid assigning to an unused variable by [@​DavidZivk](https://togithub.com/DavidZivk) in [https://github.com/ruby/debug/pull/985](https://togithub.com/ruby/debug/pull/985) - remove debug print by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1043](https://togithub.com/ruby/debug/pull/1043) - Minor punctuation and grammar fixes by [@​ahangarha](https://togithub.com/ahangarha) in [https://github.com/ruby/debug/pull/1041](https://togithub.com/ruby/debug/pull/1041) - Tests - Bump actions/checkout from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/ruby/debug/pull/1014](https://togithub.com/ruby/debug/pull/1014) #### New Contributors - [@​dependabot](https://togithub.com/dependabot) made their first contribution in [https://github.com/ruby/debug/pull/1014](https://togithub.com/ruby/debug/pull/1014) - [@​tompng](https://togithub.com/tompng) made their first contribution in [https://github.com/ruby/debug/pull/1010](https://togithub.com/ruby/debug/pull/1010) - [@​takatea](https://togithub.com/takatea) made their first contribution in [https://github.com/ruby/debug/pull/997](https://togithub.com/ruby/debug/pull/997) - [@​y-yagi](https://togithub.com/y-yagi) made their first contribution in [https://github.com/ruby/debug/pull/993](https://togithub.com/ruby/debug/pull/993) - [@​DavidZivk](https://togithub.com/DavidZivk) made their first contribution in [https://github.com/ruby/debug/pull/985](https://togithub.com/ruby/debug/pull/985) - [@​eregon](https://togithub.com/eregon) made their first contribution in [https://github.com/ruby/debug/pull/1039](https://togithub.com/ruby/debug/pull/1039) - [@​ahangarha](https://togithub.com/ahangarha) made their first contribution in [https://github.com/ruby/debug/pull/1041](https://togithub.com/ruby/debug/pull/1041) - [@​ioquatix](https://togithub.com/ioquatix) made their first contribution in [https://github.com/ruby/debug/pull/987](https://togithub.com/ruby/debug/pull/987) **Full Changelog**: ruby/debug@v1.8.0...v1.9.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/powerhome/audiences). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44Ny4yIiwidXBkYXRlZEluVmVyIjoiMzcuODcuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several commands that evaluate objects and call methods on them, such as:
If the called method acquires a mutex shared with another thread (e.g. when using Timeout), then it'd cause a deadlock as all threads are stopped.
For example, if there's an ActiveRecord Relation object stored as a local variable, and the user runs the
info
command, then it'd callinspect
on it and trigger a database query, it could cause a deadlock as described in #877.This commit fixes the issue by unfreezing all threads before evaluating those commands and freezing them again after receiving the result event.
Note: theoretically there are more commands that evaluate user program's objects, like
break Foo#bar
callsFoo.instance_method
. But in that case the problem would only arise whenFoo.instance_method
is overridden with something that'd acquire the lock, which is a far unlikely to happen.