diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c39597..b2b4d2d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Deprecated ### Removed ### Fixed +- Fixed crash where Ruby objects constructed in C can be garbage collected. ### Security ## [2.0.2] - 2019-11-19 diff --git a/test/test_nokogumbo.rb b/test/test_nokogumbo.rb index 5586c976..6db2da2c 100644 --- a/test/test_nokogumbo.rb +++ b/test/test_nokogumbo.rb @@ -1,5 +1,12 @@ # encoding: utf-8 require 'nokogumbo' + +# Make sure that Ruby objects constructed in C are treated as GC roots. +# See: https://github.com/rubys/nokogumbo/pull/150 +if GC.respond_to?(:verify_compaction_references) + GC.verify_compaction_references(toward: :empty, double_heap: true) +end + require 'minitest/autorun' class TestNokogumbo < Minitest::Test