Sergey Burladyan <eshkinkot@gmail.com> writes:
> postgres=# select xpath('count(//)', '<a></a>'::xml);
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
Hmm. Looking at the libxml2 source code makes it clear that at least
this one function (xmlXPathCompFunctionCall) needs xmlFree(NULL) to be a
no-op, because it's not checking. I don't know whether the libxml guys
would consider that a bug or not. Their API specifications are so poor
that one can't really tell if an xmlFree callback is supposed to allow
NULL or not. The wording of
http://xmlsoft.org/html/libxml-xmlmemory.html#xmlFreeFunc suggests not,
and since we've not seen this before, there's at least fairly large
sections of libxml that do not assume they can free(NULL).
Anyway, I suppose the most prudent thing to do is assume that xml_pfree
had better act like POSIX free() and allow NULL, because it's unlikely
they test their code with any other implementation ...
regards, tom lane