Project

General

Profile

Actions

Bug #15105

closed

`rb_debug_inspector_open` breaks lazy proc optimization

Added by tenderlovemaking (Aaron Patterson) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-07-28 trunk 64081) [x86_64-darwin17]
[ruby-core:88951]

Description

Calling rb_debug_inspector_open inside a block that uses lazy proc optimizations breaks the implementation. r60397 introduced the bug.

I've attached a failing test, but I'll paste the diff here as well:

From 54e55b83f1a6365ded897ebbef2da758d5739eb0 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Tue, 11 Sep 2018 14:42:24 -0700
Subject: [PATCH] add a failing test for lazy block

---
 test/-ext-/debug/test_debug.rb | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/-ext-/debug/test_debug.rb b/test/-ext-/debug/test_debug.rb
index 3804714d0d..cc1e7b7997 100644
--- a/test/-ext-/debug/test_debug.rb
+++ b/test/-ext-/debug/test_debug.rb
@@ -56,4 +56,25 @@ def test_inspector_open_in_eval
     binds = inspector_in_eval
     binds_check binds, bug7635
   end
+
+  class MyRelation
+    include Enumerable
+
+    def each(&block)
+      records.each(&block)
+    end
+
+    def records
+      [1]
+    end
+  end
+
+  def test_lazy_block
+    x = MyRelation.new.any? do
+      Bug::Debug.inspector
+      true
+    end
+
+    assert x, "any should have returned true"
+  end
 end
-- 
2.17.0

I think this ep calculation might be wrong, but I'm not totally sure: https://github.com/ruby/ruby/blob/bddc28b2aeb6ca84c9eb2cdd59ccc9b76098e429/vm.c#L726

I don't understand r60397 well enough to figure out what the correct fix is.

Thanks.


Files

0001-add-a-failing-test-for-lazy-block.patch (949 Bytes) 0001-add-a-failing-test-for-lazy-block.patch tenderlovemaking (Aaron Patterson), 09/11/2018 09:55 PM

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #15234: Running redis on the #all? block returns nilClosedActions
Has duplicate Ruby master - Bug #15325: Ruby 2.5.3 seg fault after find block returnsClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0