[xml] Any outstanding bugs in closing parser contexts or running with different memory handlers?



I'm neck deep in memory problems and am not sure where to begin
looking.  I'm actually worried I've tickled a bug in Ruby because I'm
using its malloc/free routines, but I'd like to be sure.  Since I've
swapped out the memory routines, what's left of the libxml memory
accounting, or do I have to build my own and duplicate the *Loc()
routines only have them using ruby_xmalloc, free, etc?  I've pasted
the valgrind results in case anyone's interested or wants to take a
peak:

http://www.rubynet.org/valgrind-libxml.txt
http://www.rubynet.org/valgrind-libxml.txt.bz2

ctxtClose is a blatant rip off from someplace inside of the libxml
sources:

static void ctxtClose(FILE *f) {
  if (f != stdin) {
    fclose(f);
  }
}


... so I'm not really sure why I'm getting the following cryptic
error:

==19278== Invalid read of size 1
==19278==    at 0x40308758: (within /lib/libc-2.2.5.so)
==19278==    by 0x431B10BC: ctxtClose (ruby_xml_parser.c:17)
==19278==    by 0x432BCDAA: xmlFreeParserInputBuffer (xmlIO.c:1575)
==19278==    by 0x432A01CC: xmlFreeInputStream (parserInternals.c:1923)
==19278==    by 0x432A0B29: xmlFreeParserCtxt (parserInternals.c:2313)
==19278==    by 0x431B2A83: ruby_xml_parser_context_free (ruby_xml_parser_context.c:92)

==19278== Invalid read of size 2
==19278==    at 0x40308789: (within /lib/libc-2.2.5.so)
==19278==    by 0x431B10BC: ctxtClose (ruby_xml_parser.c:17)
==19278==    by 0x432BCDAA: xmlFreeParserInputBuffer (xmlIO.c:1575)
==19278==    by 0x432A01CC: xmlFreeInputStream (parserInternals.c:1923)
==19278==    by 0x432A0B29: xmlFreeParserCtxt (parserInternals.c:2313)
==19278==    by 0x431B2A83: ruby_xml_parser_context_free (ruby_xml_parser_context.c:92)

==19278== Invalid read of size 4
==19278==    at 0x403087CB: (within /lib/libc-2.2.5.so)
==19278==    by 0x431B10BC: ctxtClose (ruby_xml_parser.c:17)
==19278==    by 0x432BCDAA: xmlFreeParserInputBuffer (xmlIO.c:1575)
==19278==    by 0x432A01CC: xmlFreeInputStream (parserInternals.c:1923)
==19278==    by 0x432A0B29: xmlFreeParserCtxt (parserInternals.c:2313)
==19278==    by 0x431B2A83: ruby_xml_parser_context_free (ruby_xml_parser_context.c:92)

What's interesting is that the read size grows from 1 to 4.  Why I'm
not sure, and think that there could be a stray bit being written to
in Ruby, but I'm not 100% sure.  Since valgrind only runs on Linux,
I'd perfectly happy to chalk this up as a linux-ism, but it crashes on
FreeBSD too.  :-/  Anyone have any thoughts?  -sc

-- 
Sean Chittenden



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]