Hi all,
happy holidays and a happy new (civil) year.
I'm the maintainer of XML::LibXSLT which are the CPAN bindings for libxslt.
Now, someone reported that the clang compiler emits some warnings, and part of
the problem was that I passed 1.0 to xmlNewDoc instead of its equivalent
xmlChar *. So I did:
xmlChar * xml_ver = NULL;
xml_ver = xmlCharStrdup(1.0);
xmlNewDoc(xml_ver)
// At the function FINISH:
free( xml_ver );
However, now it was reported that the Win32 tests generate a segfault:
https://rt.cpan.org/Ticket/Display.html?id=91652
So I tried to replace free() by xmlMemFree() but now I'm getting errors upon
make test on Linux:
[QUOTE SHELL]
shlomif[XML-LibXML]:$xslt_trunk$ hg di
diff -r 0290d4243e9b LibXSLT.xs
--- a/LibXSLT.xsSun Dec 22 18:23:22 2013 +0200
+++ b/LibXSLT.xsThu Dec 26 12:15:35 2013 +0200
@@ -249,7 +249,7 @@
XPUSHs(perl_function);
-xml_ver = xmlCharStrdup(1.0);
+ xml_ver = xmlCharStrdup(1.0);
/* clone all of the arguments into a new owning document */
owner_doc = x_PmmNodeToSv(INT2PTR(xmlNodePtr,xmlNewDoc(xml_ver)), NULL);
XPUSHs( sv_2mortal(owner_doc) );
@@ -428,11 +428,11 @@
ret = (xmlXPathObjectPtr)xmlXPathNewCString(SvPV(perl_result, len));
FINISH:
-free( xml_ver );
+xmlMemFree( xml_ver );
valuePush(ctxt, ret);
PUTBACK;
FREETMPS;
-LEAVE;
+LEAVE;
}
/*
shlomif[XML-LibXML]:$xslt_trunk$ perl Mak
Makefile Makefile.old Makefile.PL Makefile.PL~
shlomif[XML-LibXML]:$xslt_trunk$ perl Makefile.PL
running xslt-config... ok
looking for -lxslt... yes
looking for -lexslt... yes
running pkg-config libexslt... ok
Warning (mostly harmless): No library found for -ldb
Generating a GNU-style Makefile
Writing Makefile for XML::LibXSLT
Writing MYMETA.yml and MYMETA.json
shlomif[XML-LibXML]:$xslt_trunk$ make
Skip blib/lib/XML/LibXSLT.pm (unchanged)
gcc -c -I/usr/include/libxml2 -I/usr/include/libxml2 -D_REENTRANT
-D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wformat
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
--param=ssp-buffer-size=4 -fPIC -Wl,--as-needed -Wl,-z,relro -Wl,-O1
-Wl,--build-id -Wl,--enable-new-dtags -pthread -DVERSION=\1.83\
-DXS_VERSION=\1.83\ -fPIC
-I/usr/lib/perl5/5.18.1/x86_64-linux-thread-multi/CORE -DHAVE_BLANK
-DHAVE_BLANK -DHAVE_EXSLT LibXSLT.c gcc -c -I/usr/include/libxml2
-I/usr/include/libxml2 -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wformat -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC
-Wl,--as-needed -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags
-pthread -DVERSION=\1.83\ -DXS_VERSION=\1.83\ -fPIC
-I/usr/lib/perl5/5.18.1/x86_64-linux-thread-multi/CORE -DHAVE_BLANK
-DHAVE_BLANK -DHAVE_EXSLT perl-libxml-mm.c Running Mkbootstrap for XML::LibXSLT
() chmod 644 LibXSLT.bs rm -f blib/arch/auto/XML/LibXSLT/LibXSLT.so
LD_RUN_PATH=/usr/lib64 gcc -shared -O2 -g -pipe -Wformat
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
--param=ssp-buffer-size=4 -fPIC -Wl,--as-needed -Wl,-z,relro -Wl,-O1
-Wl,--build-id -Wl,--enable-new-dtags -pthread -L/usr/local/lib64 LibXSLT.o
perl-libxml-mm.o -o blib/arch/auto/XML/LibXSLT/LibXSLT.so \ -L/usr/lib64
-lxslt -lxml2 -lz -ldl -lm -lexslt -ldl -lgcrypt -lgpg-error -lnsl -lgdbm -ldl
-lm -lcrypt -lutil -lpthread -lc -lgdbm_compat \ chmod 755
blib/arch/auto/XML/LibXSLT/LibXSLT.so cp LibXSLT.bs
blib/arch/auto/XML/LibXSLT/LibXSLT.bs chmod 644
blib/arch/auto/XML/LibXSLT/LibXSLT.bs Manifying blib/man3/XML::LibXSLT.3pm
shlomif[XML-LibXML]:$xslt_trunk$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl5.18.1 -MExtUtils::Command::MM
-MTest::Harness -e undef *Test::Harness::Switches; test_harness(0,
'blib/lib', 'blib/arch') t/*.t t/01basic.t .. 1/4
Compiled against:libxslt 10128, libxml2 20901
Running: libxslt 10128, libxml2 20901
Compiled with EXSLT: yes
t/01basic.t .. ok
t/02dromeds.t ok
t/03input.t .. ok
t/04params.t . ok
t/05quick.t .. ok
t/06entities.t ... ok
t/06output.t . ok
t/07blankdoc.t ... ok
t/08literal.t ok
t/09exslt.t .. ok
t/10functions.t .. 1/38 Memory tag error occurs :1d89a78
bye
xmlMemFree(1D89AA0) error
xmlMallocBreakpoint reached on block 0
Memory tag error occurs :1d898b8
bye
xmlMemFree(1D898E0) error
xmlMallocBreakpoint reached on block 0
Memory tag error occurs :1d89ce8
bye
xmlMemFree(1D89D10) error
xmlMallocBreakpoint reached on block 0
Memory tag error occurs :1d89f28
bye
xmlMemFree(1D89F50) error
xmlMallocBreakpoint reached on block 0
Memory tag error occurs :1d8a6e8
bye
xmlMemFree(1D8A710) error
xmlMallocBreakpoint reached on block 0
Memory tag error occurs :1d8a278