[ruby-core:94802] [Ruby master Bug#16136] String corruption in 2.6.4
From:
kevin@...
Date:
2019-09-06 15:13:11 UTC
List:
ruby-core #94802
Issue #16136 has been updated by vcsjones (Kevin Jones).
I applied the patch to ruby 2.6.4 and I cannot reproduce the issue any more. This patch appears to resolve the issue for 2.6.4. Thank you very much for taking the time to investigate the issue.
```diff
diff --git a/symbol.c b/symbol.c
index f3506a02dd..a408ee052e 100644
--- a/symbol.c
+++ b/symbol.c
@@ -743,7 +743,8 @@ rb_str_intern(VALUE str)
enc = ascii;
}
else {
- str = rb_str_new_frozen(str);
+ str = rb_str_dup(str);
+ OBJ_FREEZE(str);
}
str = rb_fstring(str);
type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
```
----------------------------------------
Bug #16136: String corruption in 2.6.4
https://bugs.ruby-lang.org/issues/16136#change-81424
* Author: deivid (David Rodr刕uez)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]
* Backport: 2.5: DONTNEED, 2.6: REQUIRED
----------------------------------------
When trying to upgrade activeadmin's tests to use ruby 2.6.4, I got some very weird failures where some strings would end up containing random content. See https://circleci.com/gh/activeadmin/activeadmin/20329 for an example of those failures. Failures are somewhat random but the test suite seems to consistently fail on 2.6.4 and pass on 2.6.3. I also managed to reproduce the failures locally, sometimes very consistently, but now it's hardly ever happening... :/
I looked at the changes in 2.6.4 and it looks like https://bugs.ruby-lang.org/issues/16105 and/or https://bugs.ruby-lang.org/issues/15946 could be related, because the region of the Rails code where the corrupted string is created seems to be doing something similar to the reported issues: https://github.com/rails/rails/blob/b7e591a55f4de5f1511c3b9255b3b25159b8ba41/actionpack/lib/action_dispatch/routing/mapper.rb#L404-L412.
Sorry I'm not really sure how to create a reproducible example, or how to debug this issue. Just opening this in case it could help noticing something obviously wrong with the mentioned patches.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>