Commit 37f8a2e
committed
Ensure
Fix: #929
I don't know how it's possible, but somehow the `self` reference is
optimized out of the stack. Perhaps because we inline so aggressively
that the compiler end up spilling it on the heap.
Repro:
```ruby
require 'json'
test_data = {
"flag" => true,
"data" => 10000.times.map { [1.0] },
:flag => false,
}
10.times do
test_data.to_json
end
```
But in practice the cause was just that the issued warning calls
Hash#inspect on a big hash, which triggers GC.
So it can be triggered even more reliably with:
```ruby
require 'json'
module JSON
module Common
def self.on_mixed_keys_hash(...)
GC.start
end
end
end
test_data = {
"flag" => true,
"data" => 10000.times.map { [1.0] },
:flag => false,
}
test_data.to_json
```Generator::State is kept on the stack1 parent 062fcdd commit 37f8a2e
2 files changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1540 | 1540 | | |
1541 | 1541 | | |
1542 | 1542 | | |
1543 | | - | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
1544 | 1546 | | |
1545 | 1547 | | |
1546 | 1548 | | |
| |||
0 commit comments