Hopefully fix Ruby's GC marking stack objects after return #2291
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
rb_ensure()
was being used to handle the situation that an exceptionwas raised during the construction of the tree. For some reason, Ruby's
GC was keeping a reference to the
ParseArgs
even afterrb_ensure()
returned. This was causing
parse_args_mark()
to be called.This changes this situation by
free
function; and
Data_Wrap_Struct
toTypedData_Wrap_Struct
.This change simplifies the control flow since the
parse()
andfragment()
functions are no longer split into three pieces.It's likely that the runtime cost of an extra heap allocation is offset
by not needing
rb_ensure()
, but I didn't bother measuring this becauseone additional allocation is trivial since there's at least one
allocation per DOM node anyway.
Fixes #2276
What problem is this PR intended to solve?
#2276
Have you included adequate test coverage?
I'm unsure how to test this. Hopefully the valgrind CI jobs will let us know if I succeeded. 馃槥
Does this change affect the behavior of either the C or the Java implementations?
This is only relevant the C implementation of HTML5.