PtokaX > Bugs

PtokaX hangs on loading converted (from XML) user database


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 with old XML database from version (or, 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: C++ ---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.

Thank you for report. Found, fixed, svn updated  :)


[0] Message Index

Go to full version