diff options
author | Peter Zhu <[email protected]> | 2023-11-30 14:47:09 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-12-01 15:04:31 -0500 |
commit | 80ea7fbad871b2222b16af1bd9f39e1f1828bbd4 (patch) | |
tree | a2cb0155f9ad11b4a8f852efffffa20390e6060c /string.c | |
parent | 0ed55bf09713299201caec3ba9d9ef7ba6e8526f (diff) |
Pin embedded shared strings
Embedded shared strings cannot be moved because strings point into the
slot of the shared string. There may be code using the RSTRING_PTR on
the stack, which would pin the string but not pin the shared string,
causing it to move.
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 20 |
1 files changed, 0 insertions, 20 deletions
@@ -280,26 +280,6 @@ rb_str_make_embedded(VALUE str) } void -rb_str_update_shared_ary(VALUE str, VALUE old_root, VALUE new_root) -{ - // if the root location hasn't changed, we don't need to update - if (new_root == old_root) { - return; - } - - // if the root string isn't embedded, we don't need to touch the pointer. - // it already points to the shame shared buffer - if (!STR_EMBED_P(new_root)) { - return; - } - - size_t offset = (size_t)((uintptr_t)RSTRING(str)->as.heap.ptr - (uintptr_t)RSTRING(old_root)->as.embed.ary); - - RUBY_ASSERT(RSTRING(str)->as.heap.ptr >= RSTRING(old_root)->as.embed.ary); - RSTRING(str)->as.heap.ptr = RSTRING(new_root)->as.embed.ary + offset; -} - -void rb_debug_rstring_null_ptr(const char *func) { fprintf(stderr, "%s is returning NULL!! " |