Hello ruby-core, I need help understanding why my patch for a Nokogiri issue /seems/ to fix a SEGV under 1.9.3. I've tested my patch for ~24 hours already with no failures, but I still do not understand why my patch can fix the issue, so I am uncomfortable with my change. I've reproduced the original issue on both 1.9.3-p0 and p105 on x86_64-linux. It can take a minute to an hour to hit the SEGV. It does not appear to manifest on 1.9.2, so maybe it is a bad interaction with lazy-sweep in 1.9.3 The goal of the code I'm changing is to ensure the document object associated with a node is marked if the node is still alive: http://bogomips.org/nokogiri.git/patch/?id=a1b7f1eef74ac9d69900488a56ba96ae9144615d The SEGV was caused by attempting to mark an already-freed document object associated with a node. I'm not sure how Nokogiri would allow document to get freed while nodes still reference it. Functionally, my patch should not accomplish anything the original code did not do, so I don't know why my patch seems to fix the issue. I've read through gc.c in Ruby 1.9.3 and everything calling obj->as.data.dmark makes sense to me (as well as rb_mark_generic_ivar(), which my patch now triggers). In both cases, the Ruby GC should be marking the document and preventing it from being freed. However, only setting document as an ivar seems to be successful. The original Nokogiri issue (including further comments) is here: https://github.com/tenderlove/nokogiri/issues/616 Thanks for reading this and any help you can provide.