Skip to content

Commit

Permalink
ext: don't use FREE_IMMEDIATELY with XML::Document
Browse files Browse the repository at this point in the history
This is a tricky one to explain, but in summary, when dealloc_node_i2
parents unparented nodes, libxml2 may merge two adjacent text nodes,
which causes additional memory allocations during GC.

If the FREE_IMMEDIATELY flag is set, this will generate warnings. But
generating those warnings during GC will lead to a segfault for
reasons I haven't dug into yet.

Anyway, let's leave this flag off for now.
  • Loading branch information
flavorjones committed Mar 3, 2023
1 parent 9208336 commit 0804380
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ext/nokogiri/xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ memsize(const void *data)
}

const rb_data_type_t noko_xml_document_data_type = {
.wrap_struct_name = "Nokogiri::XML::Document",
.function = {
.dmark = mark,
.dfree = dealloc,
.dsize = memsize,
},
.flags = RUBY_TYPED_FREE_IMMEDIATELY
.wrap_struct_name = "Nokogiri::XML::Document",
.function = {
.dmark = mark,
.dfree = dealloc,
.dsize = memsize,
}
};

static void
Expand Down

0 comments on commit 0804380

Please sign in to comment.