[xml] Push Parser



Hi,

OS: Solaris 2.8+
libxml: libxml2-2.4.0

I'm having some problems with the push parser.

Basically, if I try to read files in large blocks I end up with a core
dump.

bash-2.04$ pstack core
core 'core' of 100973:  ./poolcfg -c info /var/tmp/pooladm.conf
 ddad5bbd areBlanks (dd6e6000, dd6c6237, 5) + 105
 ddada47a xmlParseCharData (dd6e6000, 0) + 322
 ddaf209c xmlParseTryOrFinish (dd6e6000, 0) + 1984
 ddaf2a9a xmlParseChunk (dd6e6000, 8045994, 62a, 0) + 142
 dd932f4a pool_xml_open_file (dd6b6000) + 332
 dd931f8f pool_xml_connection_alloc (dd6b6000, 1) + 2f7
 dd937629 pool_conf_open (dd6b6000, 80470e2, 1) + a9
 080519c1 main     (4, 8046f38, 8046f4c) + 1b1
 0804dd57 ???????? ()
bash-2.04$

The logic used to set up the read is this:

 res = fread(chars, 1, PAGE_READ_SIZE, prov->pxc_file);
 if (res > 0) {
  ctxt = xmlCreatePushParserCtxt(NULL, NULL,
      chars, res, conf->pc_location);
  xmlSetGenericErrorFunc(ctxt, pool_error_func);

  while ((res = fread(chars, 1, PAGE_READ_SIZE, prov->pxc_file)) > 0) {
   if (xmlParseChunk(ctxt, chars, res, 0) != 0) {
    pool_seterror(PERR_INVALID_CONF);
    error = FAIL;
    break;
   }
  }
  if (xmlParseChunk(ctxt, chars, 0, 1) != 0) {
   pool_seterror(PERR_INVALID_CONF);
   error = FAIL;
  }
  prov->pxc_doc = ctxt->myDoc;
  xmlFreeParserCtxt(ctxt);
 }
...

PAGE_READ_SIZE is set to the size of a page on the OS in use, either
8192 or 4096 bytes.

The problem seems to be caused by the fact that my XML files are smaller
than PAGE_READ_SIZE bytes in size. If I set PAGE_READ_SIZE to be a very
small number (4, which is smallest possible) then the program works
fine.

Anybody got any suggestions on what's wrong? It seems to me that I get
the problem if I call xmlParseChunk with the terminate flag set to 1
never having called xmlParseChunk with terminate 0.

Gary


--
Gary Pennington
Solaris Kernel Development,
Sun Microsystems
Gary Pennington sun com







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