PtokaX 0.5.0.0 hangs on loading converted (from XML) user database
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

PtokaX 0.5.0.0 hangs on loading converted (from XML) user database

Started by dmvn, 09 December, 2013, 23:45:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dmvn

Hello again, I've discovered and located a bug which I had mentioned in another topic here.

I have rather large user database, above 3k records (it seems that it may be important for this issue). The problem is following:

1) I'm starting PtokaX 0.5.0.0 with old XML database from version 0.4.1.1 (or 0.4.1.2, it does not matter).
At first run, it converts database to new binary format, and all works OK.
2) I'm stopping hub via SIGTERM (it stops gracefully)
3) On the next start, it freezes on reading RegisteredUsers.pxb every time. Pressing Ctrl+C or killing process leads to a segfault with a coredump.

I've managed to find a place in the code where infinite loop occurs:

PXBReader.cpp, loop at line ~ 130:

Code: cpp
bool PXBReader::ReadNextItem(const uint16_t * sExpectedIdentificators, const uint8_t &ui8ExpectedSubItems) {
....
    uint16_t ui16SubItemSize = 0;
    while(ui32ItemSize > 0) {
     .... // on reading some record we remain here forever
    }
   ..
}


I started playing with my user database and found interesting fact: if binary database is less than 128k, all works fine. If it grows by just 1 record to exceed this limit - conversion is performed with error (or conversion is fine and reading of large file is broken, I don't know exactly).

I'm attaching archive with two databases (passwords were replaced, so you may use it for test): GOOD_RegisteredUsers.xml is converted fine, and BAD_RegisteredUsers.xml breaks next hub execution. They differ only by 1 user record.

P.S. At a glance, binary base reading / writing code should be covered by many unit-tests. Lots of 16 / 32 bit conversions, packing, buffer window moving along the file... total brain damage :)
maybe, there are some assertions needed in pxb reading code to prevent such lockups - checking of loop invariants, etc.

PPK

"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

SMF spam blocked by CleanTalk