[fpc-pascal] Firebird 2.5 embedded bug? Debugging skills needed

Jim hakkie42 at gmail.com
Mon Dec 20 18:23:21 CET 2010


(Posted to Firebird-dev list, copied to freepascal list for info)

Hi all,

Recently I mentioned a problem running FreePascal 64 bit code with
Firebird 2.5 embedded 64 bit on Windows (Vista).
Tried a later 2.5.1 snapshot, didn't work either.
It does work with a separate regular Firebird 2.x 64 bit server.
It also works as a 32 bit program with Firebird 2.5 embedded 32 bit Windows.

Thanks to Firebird's Vlad Khorsun, Martin Schreiber and FreePascal's
Marco van de Voort, FreePascal has implemented a patch that got rid of
one error.

However, my test program still does not run correctly.
It tries deliberately running SQL that will fail, e.g. inserting data in
a non-existing table, inserting duplicate values in a column with unique
constraints, triggering a... trigger that raises a custom Firebird
exception.
All these cases seem to lead to access violations (or other errors) in
the Firebird code.

As my debugging skills are weak at best, could a kind soul extract the
zip (includes all dlls and database) in
https://bitbucket-assetroot.s3.amazonaws.com/jb/flocate/20101220/6/fbembedtest64_20December.zip
run fbservertest.exe using a debugger, generally work your spells and
tell me if I should go back to the FreePascal team or if this error
seems to be in Firebird itself (or my test code).

For comparison, a comparable exe/source code in 32 bit windows can be
found here:
https://bitbucket-assetroot.s3.amazonaws.com/jb/flocate/20100616/5/fbembedtest16June_15.10.zip

FreePascal bug report: http://mantis.freepascal.org/view.php?id=17360
Sample program run for 32 bit and 64 bit: see below:

If you need additional info, please let me know.

Finally, could someone tell me how I can run Windows x64 embedded using
the 3.0 snapshots? Simply renaming fbclient.dll to fbembedded.dll didn't
seem to work...


Thanks,
-- 
Regards,

jb

Program run on 32 bit (works) and 64 bit (doesn't work). Note the 64 bit
program has grown some more tests.
D:\Cop\embed32>fbembedtest.exe
Debug: 20-12-2010 18:07:51: Starting database setup:
Debug: 20-12-2010 18:07:51: SetUp: Connecting to database:
Debug: 20-12-2010 18:07:51: DB/Setup/Going to start transaction.
Debug: 20-12-2010 18:07:51: Getting query
===============================================================
fbembedtest: information.
Test program for firebird 2.1 embedded database and custom stored
procedures.
Please see
fbembedtest_readme.TXT
for details on setting up database etc.
Freeware but no warranties, express or implied.
For full copyright and license, please see the source code.
===============================================================
Debug: 20-12-2010 18:07:51: Application started.

*** First, clear any existing numbers out of database:
Debug: 20-12-2010 18:07:51: ClearData: going to run query DELETE FROM
NUMBERS;


*** Insert number 5. This should work:
Debug: 20-12-2010 18:07:51: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:07:51: SaveNumber: insert query code done.

*** Insert number 5 again. This shold fail because of the unique index.
*** We should get a generic database error.
Debug: 20-12-2010 18:07:51: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:07:51: Database error running insert query.
Database error
message:  : Execute :
 -violation of PRIMARY or UNIQUE KEY constraint "NUMBERUNIQUE" on table
"NUMBERS
"; Database error code: 335544665
Debug: 20-12-2010 18:07:51: Parameters were:
BINGONUMBER: *5*
Debug: 20-12-2010 18:07:51: Rolling back transaction.
Debug: 20-12-2010 18:07:51: SaveNumber: insert query code done.

*** Now test our custom Firebird exception by trying to insert 13:
Debug: 20-12-2010 18:07:51: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:07:51: Database error running insert query.
Database error
message:  : Execute :
 -exception 1
 -EXCNOT13
 -No, not 13, I can't handle that!
 -At trigger 'TRIGCHECK13' line: 7, col: 28; Database error code: 335544517
Debug: 20-12-2010 18:07:51: Parameters were:
BINGONUMBER: *13*
Debug: 20-12-2010 18:07:51: Rolling back transaction.
Debug: 20-12-2010 18:07:51: SaveNumber: insert query code done.

*** Ok, done. Let's close down the connection
Debug: 20-12-2010 18:07:51: Application finished.
Debug: 20-12-2010 18:07:51: DB/Destroy/Going to commit active transaction.
Debug: 20-12-2010 18:07:51: Disconnecting from database/running FreeAll
Heap dump by heaptrc unit
569 memory blocks allocated : 24092/25824
569 memory blocks freed     : 24092/25824
0 unfreed memory blocks : 0
True heap size : 196608 (96 used in System startup)
True free heap : 196512



64 bit test doesn't work correctly:
D:\Cop\embed64>fbembedtest.exe
Debug: 20-12-2010 18:11:17: Starting database setup:
Debug: 20-12-2010 18:11:17: SetUp: Connecting to database:
Debug: 20-12-2010 18:11:17: DB/Setup/Going to start transaction.
Debug: 20-12-2010 18:11:17: Getting query
===============================================================
fbembedtest: information.
Test program for firebird 2.x embedded database and custom stored
procedures.
Please see
fbembedtest_readme.TXT
for details on setting up database etc.
Freeware but no warranties, express or implied.
For full copyright and license, please see the source code.
===============================================================
Debug: 20-12-2010 18:11:17: Application started.

*** First, clear any existing numbers out of database:
Debug: 20-12-2010 18:11:17: ClearData: going to run query DELETE FROM
NUMBERS;

Debug: 20-12-2010 18:11:17: ClearData: query code done.
*** Executing an insert query with the wrong table, should give a db error:
Debug: 20-12-2010 18:11:17: RunSQL: going to run query INSERT INTO
THISTABLEDOES
NTEXIST (BINGONUMBER) VALUES (91)

Debug: 20-12-2010 18:11:17: RunSQL: exception running delete query.
Exception me
ssage: Control-C hitException type: EControlC
*** Executing a simple insert query without parameters:
Debug: 20-12-2010 18:11:17: RunSQL: going to run query INSERT INTO
NUMBERS (BING
ONUMBER) VALUES (91);

Debug: 20-12-2010 18:11:17: RunSQL: query code done.
*** Executing a simple insert query without parameters for the same
value. This
should fail:
Debug: 20-12-2010 18:11:17: RunSQL: going to run query INSERT INTO
NUMBERS (BING
ONUMBER) VALUES (91);

Debug: 20-12-2010 18:11:17: RunSQL: exception running delete query.
Exception me
ssage: Control-C hitException type: EControlC
*** Executing a simple delete query without parameters:
Debug: 20-12-2010 18:11:17: RunSQL: going to run query DELETE FROM
NUMBERS WHERE
 BINGONUMBER=91;

Debug: 20-12-2010 18:11:17: RunSQL: exception running delete query.
Exception me
ssage: Access violationException type: EAccessViolation
*** Insert number 5. This should work:
Debug: 20-12-2010 18:11:17: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:11:17: SaveNumber: going to execute the insert query.
Debug: 20-12-2010 18:11:17: SaveNumber: insert query code done.
*** Insert number 5 again. This should fail because of the unique index.
*** We should get a generic database error.
Debug: 20-12-2010 18:11:17: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:11:17: SaveNumber: going to execute the insert query.
Debug: 20-12-2010 18:11:17: SaveNumber: non-database exception running
query. Ex
ception message: Access violationException type: EAccessViolation
Debug: 20-12-2010 18:11:17: For reference, the parameters were:
BINGONUMBER: *5*
Debug: 20-12-2010 18:11:17: SaveNumber: insert query code done.
*** Now test our custom Firebird exception by trying to insert 13:
Debug: 20-12-2010 18:11:17: SaveNumber: going to add parameters for
insert query

Debug: 20-12-2010 18:11:17: SaveNumber: going to execute the insert query.
Debug: 20-12-2010 18:11:17: SaveNumber: non-database exception running
query. Ex
ception message: Access violationException type: EAccessViolation
Debug: 20-12-2010 18:11:17: For reference, the parameters were:
BINGONUMBER: *13*
Debug: 20-12-2010 18:11:17: SaveNumber: insert query code done.
*** Ok, done. Let's close down the connection
Debug: 20-12-2010 18:11:17: Application finished.
Debug: 20-12-2010 18:11:17: Destroy: Going to commit active transaction.
Debug: 20-12-2010 18:11:17: Destroy: Transaction committed.
Debug: 20-12-2010 18:11:17: FreeAll: Disconnecting from database.
Heap dump by heaptrc unit
689 memory blocks allocated : 45093/47256
689 memory blocks freed     : 45093/47256
0 unfreed memory blocks : 0
True heap size : 196608 (160 used in System startup)
True free heap : 196448



More information about the fpc-pascal mailing list