Skip to content

fix: SAX::ParserContext keeps a reference to the input#3395

Merged
flavorjones merged 1 commit intomainfrom
flavorjones-fix-parser-context-references
Dec 29, 2024
Merged

fix: SAX::ParserContext keeps a reference to the input#3395
flavorjones merged 1 commit intomainfrom
flavorjones-fix-parser-context-references

Conversation

@flavorjones
Copy link
Member

What problem is this PR intended to solve?

I saw a failure in CI at https://github.com/sparklemotion/nokogiri/actions/runs/12529532790/job/34945362057?pr=3393

  1) Error:
Nokogiri::HTML4::SAX::ParserContext::constructor::encoding::.io#test_0001_supports passing encoding name:
NotImplementedError: method `read' called on terminated object (0x0000005520809790)
    test/html4/sax/test_parser_context.rb:60:in `parse_with'
    test/html4/sax/test_parser_context.rb:60:in `block (5 levels) in <module:SAX>'

So now the class keeps a reference to the input object to prevent it from being GCed before we parse it.

Have you included adequate test coverage?

Yes.

Does this change affect the behavior of either the C or the Java implementations?

N/A

to prevent it from being GCed before we parse it.
@flavorjones flavorjones added this to the v1.18.x patch releases milestone Dec 29, 2024
@flavorjones flavorjones added the topic/memory Segfaults, memory leaks, valgrind testing, etc. label Dec 29, 2024
@flavorjones flavorjones merged commit 82ffa0c into main Dec 29, 2024
@flavorjones flavorjones deleted the flavorjones-fix-parser-context-references branch December 29, 2024 13:58
flavorjones added a commit that referenced this pull request Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic/memory Segfaults, memory leaks, valgrind testing, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant