ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:96794] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
@ 2020-01-11 22:44 ` me
  2020-01-12 18:19 ` [ruby-core:96810] " ko1
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: me @ 2020-01-11 22:44 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been reported by jnchito (Junichi Ito).

----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503

* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:96810] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
  2020-01-11 22:44 ` [ruby-core:96794] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0 me
@ 2020-01-12 18:19 ` ko1
  2020-01-12 18:36 ` [ruby-core:96811] " ko1
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ko1 @ 2020-01-12 18:19 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been updated by ko1 (Koichi Sasada).


Could you make reproducible script?


----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503#change-83804

* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:96811] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
  2020-01-11 22:44 ` [ruby-core:96794] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0 me
  2020-01-12 18:19 ` [ruby-core:96810] " ko1
@ 2020-01-12 18:36 ` ko1
  2020-01-12 18:40 ` [ruby-core:96813] " ko1
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ko1 @ 2020-01-12 18:36 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been updated by ko1 (Koichi Sasada).


All right. I got a script:

```ruby
loop{
  h = {a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8}
  h.each{|k,v| GC.start; h.delete(k)}
}
```

The patch is:

```diff
diff --git a/hash.c b/hash.c
index 878f2b1790..644f85d6da 100644
--- a/hash.c
+++ b/hash.c
@@ -974,6 +974,7 @@ ar_foreach_check(VALUE hash, st_foreach_check_callback_func *func, st_data_t arg
 
             switch (retval) {
               case ST_CHECK: {
+                  pair = RHASH_AR_TABLE_REF(hash, i);
                   if (pair->key == never) break;
                   ret = ar_find_entry_hint(hash, hint, key);
                   if (ret == RHASH_AR_TABLE_MAX_BOUND) {
```

This patch should be back-ported for Ruby 2.6.

Thank you for your report.

----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503#change-83806

* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [ruby-core:96813] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2020-01-12 18:36 ` [ruby-core:96811] " ko1
@ 2020-01-12 18:40 ` ko1
  2020-01-12 18:44 ` [ruby-core:96815] " ko1
  2020-01-12 23:34 ` [ruby-core:96819] " me
  5 siblings, 0 replies; 6+ messages in thread
From: ko1 @ 2020-01-12 18:40 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been updated by ko1 (Koichi Sasada).


> This patch should be back-ported for Ruby 2.6.

sorry I mean 2.7. 2.6 doesn't have this problem.


----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503#change-83808

* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:96815] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2020-01-12 18:40 ` [ruby-core:96813] " ko1
@ 2020-01-12 18:44 ` ko1
  2020-01-12 23:34 ` [ruby-core:96819] " me
  5 siblings, 0 replies; 6+ messages in thread
From: ko1 @ 2020-01-12 18:44 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been updated by ko1 (Koichi Sasada).

Status changed from Open to Closed

350dafd56a9cff58d36303aeb7515ab41c5dbbb3

----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503#change-83810

* Author: jnchito (Junichi Ito)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:96819] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0
       [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2020-01-12 18:44 ` [ruby-core:96815] " ko1
@ 2020-01-12 23:34 ` me
  5 siblings, 0 replies; 6+ messages in thread
From: me @ 2020-01-12 23:34 UTC (permalink / raw)
  To: ruby-core

Issue #16503 has been updated by jnchito (Junichi Ito).


Thank you very much for your quick fix. I left a comment in the meta-tags issue:

https://github.com/kpumuk/meta-tags/issues/209

----------------------------------------
Bug #16503: "ret: 2, hash modified during iteration" error in Ruby 2.7.0
https://bugs.ruby-lang.org/issues/16503#change-83813

* Author: jnchito (Junichi Ito)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] (heroku-18 stack)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I am running a Rails app on Heroku. After upgrading to Ruby 2.7, I sometimes get `ret: 2, hash modified during iteration` error.

The same issue is reported here (I'm using meta-tags gem too):
https://github.com/kpumuk/meta-tags/issues/209

This gem deletes elements while iterating hash (HashWithIndifferentAccess actually), so I guess it might involve this error:
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L168
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/renderer.rb#L181
https://github.com/kpumuk/meta-tags/blob/v2.13.0/lib/meta_tags/meta_tags_collection.rb#L85

However, this error does not occur every time (sometimes works, sometimes fails), and it didn't occur in Ruby 2.6. So I'm wondering why. Do you have any idea on this?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-12 23:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16503.20200111224456@ruby-lang.org>
2020-01-11 22:44 ` [ruby-core:96794] [Ruby master Bug#16503] "ret: 2, hash modified during iteration" error in Ruby 2.7.0 me
2020-01-12 18:19 ` [ruby-core:96810] " ko1
2020-01-12 18:36 ` [ruby-core:96811] " ko1
2020-01-12 18:40 ` [ruby-core:96813] " ko1
2020-01-12 18:44 ` [ruby-core:96815] " ko1
2020-01-12 23:34 ` [ruby-core:96819] " me

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).