On 9/3/21 11:54 AM, Mike Kaganski wrote:
Hi!

I understand that the question is less than ideal, and I'm sorry for that. I'm trying to debug a very strange bug in Firebird built into LibreOffice (embedded DB functionality). A specific ODB (a package that contains a FB database) crashes executing a query 'SELECT DISTINCT "ТипВорот" FROM "ВОРОТА"', with the field used in the query is a Varchar; and I was able to debug up to the point at Sort::diddleKey, where for some reason the following line:

  const USHORT fill = n - sizeof(USHORT) - vlen;

has n less than (sizeof(USHORT) + vlen), resulting in a large resulting value, which then in the following line:

  memset(fill_pos, fill_char, fill);

results in access violation.

Additionally, the wrong value of vlen seems to be set in the same function at

  ((vary*) p)->vary_length = *((USHORT*) (record + key->skd_vary_offset));

but I fail to follow the logic why that happens.

I tried to extract the database, and use isql tool to perform the same query interactively - and that works fine. I also have cloned and built FB from its github repo in DEBUG mode, in the hope that it could allow me to catch the condition in the debugger - bit in it, the problem is never met.

I actually suspect that our integration might do something wrong initializing the engine, but I am very inexperienced in FB development, and can't easily see what's wrong there.

I doubt much that wrong init can cause such kind of errors. But I see russian letters here, which are 2 bytes in utf8 but 1 - in cp1251. Could it be related with differnt connection charset or something else like that? In what charset does LO talk to FB?


LibreOffice project uses FB 3. I am debugging on Windows using VS. I would be glad for any advise where to look/put a breakpoint/etc to nail down the project. Possibly my poor description could still make some dev here to tell "Of course, it's Foo; how could he not know that basic thing!" - that would be super-cool :)


Always useful to add stack trace (preferanly wih line numbers). DB metadata is also welcome.




Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to