Author Topic: PtokaX hangs on loading converted (from XML) user database  (Read 1011 times)

0 Members and 1 Guest are viewing this topic.

Offline dmvn

  • Member
  • ***
  • Posts: 27
  • Karma: +3/-0
    • DMVN Educational Project
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++
  1. bool PXBReader::ReadNextItem(const uint16_t * sExpectedIdentificators, const uint8_t &ui8ExpectedSubItems) {
  2. ....
  3.     uint16_t ui16SubItemSize = 0;
  4.     while(ui32ItemSize > 0) {
  5.      .... // on reading some record we remain here forever
  6.     }
  7.    ..
  8. }

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.

PtokaX forum

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 475
  • Karma: +209/-22
  • PtokaX developer
Re: PtokaX hangs on loading converted (from XML) user database
« Reply #1 on: 10 December, 2013, 19:10:28 »
Thank you for report. Found, fixed, svn updated  :)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

PtokaX forum

Re: PtokaX hangs on loading converted (from XML) user database
« Reply #1 on: 10 December, 2013, 19:10:28 »