-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.0209: test suite fails and new compile time warnings with libxml 2.12.0 #81
Comments
The failing test can be reduced to:
The output looks like a random string is parsed because the exact invalid bytes changes with each run:
Valgrind reveals memory errors:
|
It could be a bug in Perl. If the sub handler looks like this:
It fails:
and valgrind reports the errors. But If you comment out the join() line:
It stops reporting the errors. The trigger is join() called on @_ and undef as the last item. |
Just a s note that a string produced by join(... ,undef) does not contain NUL bytes. I verified it with Devel::Peek and with dumping the value from LibXML.xs. |
I think I found it. LibXML_load_external_entity() does:
A problem is that xmlParserInputBufferCreateMem() does not copy memory pointed by results_pv. It only stores the pointer and expets the memory is valid until destroying the xmlParserInputPtr. But that's not true. results_pv's memory is deallocated with PUTBACK;FREETMPS. We need to to duplicate the string, or better make results immortal and destroy it with xmlParserInputPtr. |
With libxml2-2.12.0 and perl-5.38.0 t/44extent.t failed: $ perl -Iblib/{lib,arch} ./t/44extent.t 1..7 Entity: line 1: parser error : Char 0x0 out of allowed range pseudoroot ^ Entity: line 1: parser error : PCDATA invalid Char value 0 pseudoroot ^ [...] :8: parser error : Entity 'b' failed to parse <b>&b;</b> ^ # Looks like your test exited with 2 before it could output anything. The cause was xmlParserInputBufferCreateMem() which does not copy a supplied buffer. A string returned by the ext_ent_handler handler. As a result, libxml2 read from a deallocated memory parsing random garbage. This patch fixes it by copying the string with xmlParserInputBufferPush(). shlomif#81
libxml2 maintainer here. This is a regression in libxml2 and will be fixed soon. |
This should be fixed in libxml2 master here: https://gitlab.gnome.org/GNOME/libxml2/-/commit/c2bbeed1fdf500d33ecf9a07213ab6088d255357 The fix will be included in the upcoming 2.12.4 release. |
I confirm that after applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/c2bbeed1fdf500d33ecf9a07213ab6088d255357.patch towards libxml2-2.12.3, and then running
|
libxml2 2.12.4 containing the fix is available now: https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.12.4 |
Just tested perl-XML-LibXML with new ibxml2 2.12.4 and test suite is OK now. + cd XML-LibXML-2.0209
+ THREAD_TEST=0
+ /usr/bin/make -O -j48 V=1 VERBOSE=1 test
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- LibXML.bs blib/arch/auto/XML/LibXML/LibXML.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-report-prereqs.t .............................. ok
#
#
# Compiled against libxml2 version: 21204
# Running libxml2 version: 21204
#
t/01basic.t ........................................ ok
t/02parse.t ........................................ ok
t/03doc.t .......................................... ok
t/04node.t ......................................... ok
t/05text.t ......................................... ok
t/06elements.t ..................................... ok
t/07dtd.t .......................................... ok
t/08findnodes.t .................................... ok
t/09xpath.t ........................................ ok
t/10ns.t ........................................... ok
t/11memory.t ....................................... skipped: These tests are for authors only!
t/12html.t ......................................... ok
t/13dtd.t .......................................... ok
t/14sax.t .......................................... ok
t/15nodelist.t ..................................... ok
t/16docnodes.t ..................................... ok
t/17callbacks.t .................................... ok
t/18docfree.t ...................................... ok
t/19die_on_invalid_utf8_rt_58848.t ................. ok
t/19encoding.t ..................................... ok
t/20extras.t ....................................... ok
t/21catalog.t ...................................... ok
t/23rawfunctions.t ................................. ok
t/24c14n.t ......................................... ok
t/25relaxng.t ...................................... ok
t/26schema.t ....................................... ok
t/27new_callbacks_simple.t ......................... ok
t/28new_callbacks_multiple.t ....................... ok
t/29id.t ........................................... ok
t/30keep_blanks.t .................................. ok
t/30xpathcontext.t ................................. ok
t/31xpc_functions.t ................................ ok
t/32xpc_variables.t ................................ ok
t/35huge_mode.t .................................... ok
t/40reader.t ....................................... ok
t/40reader_mem_error.t ............................. ok
t/41xinclude.t ..................................... ok
t/42common.t ....................................... ok
t/43options.t ...................................... ok
t/44extent.t ....................................... ok
t/45regex.t ........................................ ok
t/46err_column.t ................................... ok
t/47load_xml_callbacks.t ........................... ok
t/48_gh_pr63_detect_undef_values.t ................. ok
t/48_memleak_rt_83744.t ............................ ok
t/48_reader_undef_warning_on_empty_str_rt106830.t .. ok
t/48_removeChild_crashes_rt_80395.t ................ ok
t/48_replaceNode_DTD_nodes_rT_80521.t .............. ok
t/48_RH5_double_free_rt83779.t ..................... ok
t/48_rt123379_setNamespace.t ....................... ok
t/48_rt55000.t ..................................... ok
t/48_rt93429_recover_2_in_html_parsing.t ........... ok
t/48_SAX_Builder_rt_91433.t ........................ ok
t/48importing_nodes_IDs_rt_69520.t ................. ok
t/49_load_html.t ................................... ok
t/49callbacks_returning_undef.t .................... ok
t/49global_extent.t ................................ ok
t/50devel.t ........................................ ok
t/51_parse_html_string_rt87089.t ................... ok
t/60error_prev_chain.t ............................. ok
t/60struct_error.t ................................. ok
t/61error.t ........................................ ok
t/62overload.t ..................................... ok
t/71overloads.t .................................... ok
t/72destruction.t .................................. ok
t/80registryleak.t ................................. ok
t/90shared_clone_failed_rt_91800.t ................. skipped: optional (set THREAD_TEST=1 to run these tests)
t/90stack.t ........................................ ok
t/90threads.t ...................................... skipped: optional (set THREAD_TEST=1 to run these tests)
t/91unique_key.t ................................... ok
t/cpan-changes.t ................................... skipped: These tests are for authors only!
t/namespace-magic-scalar-rt144415.t ................ ok
t/pod-files-presence.t ............................. skipped: only for AUTHORS
t/pod.t ............................................ skipped: These tests are for authors only!
t/release-kwalitee.t ............................... skipped: These tests are for authors only!
t/style-trailing-space.t ........................... skipped: These tests are for authors only!
All tests successful.
Files=77, Tests=2547, 7 wallclock secs ( 0.61 usr 0.23 sys + 5.69 cusr 1.10 csys = 7.63 CPU)
Result: PASS |
2.0210 2024-01-24 - Fix copying external entity from an ext_ent_handler handler - shlomif/perl-XML-LibXML#81 - thanks to Petr - libxml-mm: Fix function prototypes in function pointers - thanks to Khem Raj
…version 2.0210 2.0210 2024-01-24 - Fix copying external entity from an ext_ent_handler handler - shlomif/perl-XML-LibXML#81 - thanks to Petr - libxml-mm: Fix function prototypes in function pointers - thanks to Khem Raj
Here is build result:
And test suite:
The text was updated successfully, but these errors were encountered: