From: "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
Date: 2023-08-19T10:12:10+00:00
Subject: [ruby-core:114413] [Ruby master Bug#19841] Marshal.dump stack overflow with recursive Time

Issue #19841 has been updated by nobu (Nobuyoshi Nakada).


Not only would be data compatibility broken, but I think data created by "remembering" the index of an instance first cannot be loaded.
This is a case specific to `TYPE_USERDEF`.
Instance variables of such types are dumped/loaded via a transient string, using `_dump`/`_load` singleton methods.
At loading, the target instance will be created in `_load`, the instance variables can not refer that instance which is not created yet.

----------------------------------------
Bug #19841: Marshal.dump stack overflow with recursive Time
https://bugs.ruby-lang.org/issues/19841#change-104162

* Author: segiddins (Samuel Giddins)
* Status: Open
* Priority: Normal
* ruby -v: 3.2.2
* Backport: 3.0: WONTFIX, 3.1: REQUIRED, 3.2: REQUIRED
----------------------------------------
``` ruby
#!/usr/bin/env ruby

puts RUBY_VERSION

t = Time.at(0, 1, :nanosecond)
t.instance_variable_set :@itself, t

Marshal.dump(t)
```

Yields a stack overflow error from the `Marshal.dump` call, even though Marshal is explicitly able to handle cyclical references




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/