Re: BUG #15420: Server crash. Segmentation fault when parsing xml file - Mailing list pgsql-bugs

From Sergey Mirvoda
Subject Re: BUG #15420: Server crash. Segmentation fault when parsing xml file
Date
Msg-id CALkWArg-fBxB+pHn440BFm_+eOmihPny44ObqBGoEZG9Y9DAiQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #15420: Server crash. Segmentation fault when parsing xml file  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: BUG #15420: Server crash. Segmentation fault when parsing xmlfile  (Andrey Borodin <x4mmm@yandex-team.ru>)
Re: BUG #15420: Server crash. Segmentation fault when parsing xml file  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs

чт, 4 окт. 2018, 16:20 Pavel Stehule <pavel.stehule@gmail.com>:


čt 4. 10. 2018 v 12:18 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:
Hi

čt 4. 10. 2018 v 12:12 odesílatel Sergey Mirvoda <sergey@mirvoda.com> napsal:


On Thu, Oct 4, 2018 at 2:11 PM Michael Paquier <michael@paquier.xyz> wrote:
If you can, could you please attach this file to this thread?  This is
important for the archives.
--
Michael

Looks like it is too big to send uncompressed, here it is in zip archive

I am try to import this xml to Postgres with pgimportdoc


and looks like some libxml2 issue.

pgimportdoc: Unexpected result status: PGRES_FATAL_ERROR
pgimportdoc: Error: ERROR:  invalid XML content
DETAIL:  line 178950: internal error: Huge input lookup
� органе Пенсионного фонда Российской Федер
                                                                               ^
line 178950: attributes construct error

I checked Sergey's example, and it doesn't crash on Linux - The error is displayed correctly. Looks like MS Windows issue of libxml2

postgres=# select xml_is_well_formed(d) from convert_from(pg_read_binary_file('error.xml'),'windows-1251') g(d);
┌────────────────────┐
│ xml_is_well_formed │
╞════════════════════╡
│ f                  │
└────────────────────┘
(1 row)

This issue can be enforced by relatively new libxml2 limits


Unfortunately, default configuration uses xmlParseBalancedChunkMemory for parsing content, and this function cannot to get option like
XML_PARSE_HUGE
So it is hard to fix it.

Regards

Pavel

Actually we found this error in very fresh intatallation of Ubuntu 16.04 and postgres 10.5
After that we checked every configuration we have. 
And only postgres 9.4 works as expected. 

Additionally Andrey just reproduced this on his dev box. 

--Regards, Sergey Mirvoda

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #15420: Server crash. Segmentation fault when parsing xml file
Next
From: Pavel Stehule
Date:
Subject: Re: BUG #15420: Server crash. Segmentation fault when parsing xml file