Age | Commit message (Collapse) | Author |
---|
| Notes: Merged: https://.com/ruby/ruby/pull/13142 |
| Notes: Merged: https://.com/ruby/ruby/pull/12740 |
| The following snippet results with a SEGV: ```ruby C = Class.new do alias_method :new_to_s, :to_s end TracePoint.new(:c_call, &:parameters).enable { C.new.new_to_s } ``` at MRI 3.3.6 and ruby 3.4.0dev The root cause of the issue lies in the `rb_tracearg_parameters` function within the `RUBY_EVENT_C_RETURN` branch. Specifically, when the invoked method is an alias for a C function, `rb_method_entry_without_refinements(..., trace_arg->called_id, ...)` may return NULL. In that case we can fallback to `trace_arg->id`. Notes: Merged: https://.com/ruby/ruby/pull/12186 |
| - ISO C forbids conversion of function pointer to object pointer type - ISO C forbids conversion of object pointer to function pointer type |
| TracePoints with incompatible events (i.e. events not in ISEQ_TRACE_EVENTS) with a method target will fail an assertion error because it does not filter for the supported events. For example, the following lines will cause an assertion error: def foo; end # No arguments passed into TracePoint.new enables all ISEQ_TRACE_EVENTS TracePoint.new {}.enable(target: method(:foo)) # Raise is not supported with a target TracePoint.new(:raise, :return) {}.enable(target: method(:foo)) foo Crashes with: Assertion Failed: vm_insnhelper.c:7026:vm_trace:(iseq_local_events & ~(0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010| 0x0020| 0x0040 | 0x0100 | 0x0200 | 0x4000 | 0x010000| 0x020000)) == 0 Notes: Merged: https://.com/ruby/ruby/pull/11390 |
| |
| This frees FL_USER0 on both T_MODULE and T_CLASS. Note: prior to this, FL_SINGLETON was never set on T_MODULE, so checking for `FL_SINGLETON` without first checking that `FL_TYPE` was `T_CLASS` was valid. That's no longer the case. |
| [Feature #16495] |
| [Bug #20194] When disabling the TracePoint on bmethod, the hooks list is not freed. For example: obj = Object.new obj.define_singleton_method(:foo) {} bmethod = obj.method(:foo) tp = TracePoint.new(:return) {} 10.times do 100_000.times do tp.enable(target: bmethod) {} end puts `ps -o rss= -p #{$$}` end Before: 18208 22832 26528 29728 34000 37776 40864 44400 47680 51504 After: 16688 17168 17168 17248 17696 17760 17824 17824 17856 17920 |
| to BUILTIN_ATTR_SINGLE_NOARG_LEAF The attribute was created when the other attribute was called BUILTIN_ATTR_INLINE. Now that the original attribute is renamed to BUILTIN_ATTR_LEAF, it's only confusing that we call it "_INLINE". |
| |
| This argument doesn't seem used anymore. Since we want to free these objects during VM destruction when RUBY_FREE_AT_EXIT is set they must work without an EC. This avoids a use-after-free running `RUBY_FREE_AT_EXIT=1 ./miniruby -e ''` |
| Just removes the unneeded `prereg_` prefix from a few local var names. |
| |
| for future extensions. |
| Our current implementation of rb_postponed_job_register suffers from some safety issues that can lead to interpreter crashes (see bug #1991). Essentially, the issue is that jobs can be called with the wrong arguments. We made two attempts to fix this whilst keeping the promised semantics, but: * The first one involved masking/unmasking when flushing jobs, which was believed to be too expensive * The second one involved a lock-free, multi-producer, single-consumer ringbuffer, which was too complex The critical insight behind this third solution is that essentially the only user of these APIs are a) internal, or b) profiling gems. For a), none of the usages actually require variable data; they will work just fine with the preregistration interface. For b), generally profiling gems only call a single callback with a single piece of data (which is actually usually just zero) for the life of the program. The ringbuffer is complex because it needs to support multi-word inserts of job & data (which can't be atomic); but nobody actually even needs that functionality, really. So, this comit: * Introduces a pre-registration API for jobs, with a GVL-requiring rb_postponed_job_prereigster, which returns a handle which can be used with an async-signal-safe rb_postponed_job_trigger. * Deprecates rb_postponed_job_register (and re-implements it on top of the preregister function for compatability) * Moves all the internal usages of postponed job register pre-registration |
| |
| |
| `c-call` and `c-return events no longer pass the nearest Ruby method binding. Notes: Merged: https://.com/ruby/ruby/pull/8364 |
| - Clarify the class of event parameters - Represent event names as strings - Update the example to show the above Notes: Merged: https://.com/ruby/ruby/pull/8364 |
| Notes: Merged: https://.com/ruby/ruby/pull/8364 |
| fix [Feature #19572] Notes: Merged: https://.com/ruby/ruby/pull/8150 |
| |
| If the iseq only contains `opt_invokebuiltin_delegate_leave` insn and the builtin-function (bf) is inline-able, the caller doesn't need to build a method frame. `vm_call_single_noarg_inline_builtin` is fast path for such cases. Notes: Merged: https://.com/ruby/ruby/pull/7486 |
| Notes: Merged: https://.com/ruby/ruby/pull/7462 |
| Notes: Merged: https://.com/ruby/ruby/pull/7459 |
| Right now the attached object is stored as an instance variable and all the call sites that either get or set it have to know how it's stored. It's preferable to hide this implementation detail behind accessors so that it is easier to change how it's stored. Notes: Merged: https://.com/ruby/ruby/pull/7308 |
| Notes: Merged: https://.com/ruby/ruby/pull/7156 |
| trace_arg->id is the ID of the original method of an aliased method. If the original method is removed, then the lookup will fail. We should use trace_arg->called_id instead, which is the ID of the aliased method. Fixes [Bug #19305] Notes: Merged: https://.com/ruby/ruby/pull/7064 |
| I noticed this while running test_yjit with --mjit-call-threshold=1, which redefines `Integer#<`. When Ruby is monkey-ed, MJIT itself could be broken. Similarly, Ruby scripts could break MJIT in many different ways. I prepared the same set of hooks as YJIT so that we could possibly override it and disable it on those moments. Every constant under RubyVM::MJIT is private and thus it's an unsupported behavior though. Notes: Merged-By: k0kubun <[email protected]> |
| This makes sure the method returns nil for these events, as described in NEWS, even if the TracePoint could create a binding. Notes: Merged: https://.com/ruby/ruby/pull/6984 Merged-By: jeremyevans <[email protected]> |
| Notes: Merged: https://.com/ruby/ruby/pull/6721 |
| It seems more readable to put JIT invalidation code together. |
| Follow-up for 2b8191bdad7545b71f270d2b25a34cd2b3afa02f. Since that commit, we stopped doing code invalidation the second time the call and return events are enabled. We need to do it every time these events are enabled because we might have generated code while these events are disabled. Also rename locals and edit comments to make it more clear that the iseq rewrite code path only happens the first time a particular iseq trace event is enabled. Notes: Merged-By: maximecb <[email protected]> |
| Notes: Merged-By: maximecb <[email protected]> |
| [Misc #18891] Notes: Merged: https://.com/ruby/ruby/pull/6094 |
| Previously, we didn't pop the frame that runs the TracePoint hook for b_return events for blocks running as methods (bmethods). In case the hook raises, that formed an infinite loop during stack unwinding in hook_before_rewind(). [Bug #18060] Notes: Merged: https://.com/ruby/ruby/pull/4638 |
| df317151a5b4e0c5a30fcc321a9dc6abad63f7ed removed the code to free rb_hook_list_t, so repeated targeting of the same bmethod started to the hook list. You can observe how the maximum memory use scales with input size in the following script with `/usr/bin/time -v`. ```ruby o = Object.new o.define_singleton_method(:foo) {} trace = TracePoint.new(:return) {} bmethod = o.method(:foo) ARGV.first.to_i.times { trace.enable(target:bmethod){} } 4.times {GC.start} ``` After this change the maximum doesn't grow as quickly. To plug the , check whether the hook list is already allocated when enabling the targeting TracePoint for the bmethod. This fix also allows multiple TracePoints to target the same bmethod, similar to other valid TracePoint targets. Finally, free the rb_hook_list_t struct when freeing the method definition it lives on. Freeing in the GC is a good way to avoid lifetime problems similar to the one fixed in df31715. [Bug #18031] Notes: Merged: https://.com/ruby/ruby/pull/4651 |
| Check whether the current or previous frame is a Ruby frame in call_trace_func and rb_tracearg_binding before attempting to create a binding for the frame. Fixes [Bug #18487] Co-authored-by: Alan Wu <[email protected]> Notes: Merged: https://.com/ruby/ruby/pull/5767 Merged-By: jeremyevans <[email protected]> |
| This reverts commit 343ea9967e4a6b279eed6bd8e81ad0bdc747f254. This causes an assertion failure with -DRUBY_DEBUG=1 -DRGENGC_CHECK_MODE=2 |
| * Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <[email protected]> Notes: Merged-By: ioquatix <[email protected]> |
| This is more backwards compatible, and should fix issues with power_assert. Unfortunately, it requires using a sentinel value as the default value of target_thread, instead of the more natural expression used in the original approach. Notes: Merged: https://.com/ruby/ruby/pull/5359 |
| Check whether the current or previous frame is a Ruby frame in call_trace_func before attempting to create a binding for the frame. Fixes [Bug #18487] Co-authored-by: Alan Wu <[email protected]> Notes: Merged: https://.com/ruby/ruby/pull/5567 |
| https://rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20220122T050018Z.log.html.gz#miniruby ``` compiling vm_trace.c vm_trace.c: In function 'rb_vm_memsize_postponed_job_buffer': vm_trace.c:1599:1: error: old-style function definition [-Werror=old-style-definition] 1599 | rb_vm_memsize_postponed_job_buffer() | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` |
| Currently the calculation only counts the size of the struct. This commit adds the size of the associated st tables, id tables, and linked lists. Still missing is the size of the ractors and (potentially) the size of the object space. Notes: Merged: https://.com/ruby/ruby/pull/5428 |
| It free `rb_hook_list_t` itself if needed. To recognize the need, this introduced `rb_hook_list_t::is_local` flag. This is succession of https://.com/ruby/ruby/pull/4652 Notes: Merged: https://.com/ruby/ruby/pull/5253 |
| `rb_clear_attr_ccs()` should be called only when c_call or c_return is activated. Notes: Merged: https://.com/ruby/ruby/pull/5261 |
| In general, while TracePoint callback is running, other registerred callbacks are not called to avoid confusion by reentrace. This method allow the reentrace. This method should be used carefully, otherwize the callback can be easily called infinitely. [Feature #15912] Co-authored-by: Jean Boussier <[email protected]> Notes: Merged: https://.com/ruby/ruby/pull/5231 |
| The main impetus for this change is to fix [Bug #13392]. Previously, we fired the "return" TracePoint event after popping the stack frame for the block running as method (BMETHOD). This gave undesirable source location outputs as the return event normally fires right before the frame going away. The iseq for each block can run both as a block and as a method. To accommodate that, this commit makes vm_trace() fire call/return events for instructions that have b_call/b_return events attached when the iseq is running as a BMETHOD. The logic for rewriting to "trace_*" instruction is tweaked so that when the user listens to call/return events, instructions with b_call/b_return become trace variants. To continue to provide the return value for non-local returns done using the "return" or "break" keyword inside BMETHODs, the stack unwinding code is tweaked. b_return events now provide the same return value as return events for these non-local cases. A pre-existing test deemed not providing a return value for these b_return events as a limitation. This commit removes the checks for call/return TracePoint events that happen when calling into BMETHODs when no TracePoints are active. Technically, migrating just the return event is enough to fix the bug, but migrating both call and return removes our reliance on `VM_FRAME_FLAG_FINISH` and re-entering the interpreter when the caller is already in the interpreter. Notes: Merged: https://.com/ruby/ruby/pull/4637 |
| After 5680c38c75aeb5cbd219aafa8eb48c315f287d97, postponed job APIs now expect to be called on native threads not managed by Ruby and handles getting a NULL execution context. However, in debug builds the change runs into an assertion failure with GET_EC() which asserts that EC is non-NULL. Avoid the assertion failure by passing `false` for `expect_ec` instead as the intention is to handle when there is no EC. Add a test from John Crepezzi and John Hawthorn to exercise this situation. See GH-4108 See GH-5094 [Bug #17573] Co-authored-by: John Hawthorn <[email protected]> Co-authored-by: John Crepezzi <[email protected]> Notes: Merged: https://.com/ruby/ruby/pull/5156 Merged-By: XrXr |