[fpc-pascal] DLL calling Firebird 2: crashes at the end

Reinier Olislagers reinierolislagers at gmail.com
Sun Sep 28 09:39:50 CEST 2014

After hopefully getting parameter passing fixed (I hope, thanks Mark),
I'm still facing this problem:
dll using Firebird crashes on Windows and Linux
Using a dummy db unit that does not connect to Firebird: everything ok.

Compiler options on a Windows compile:
 -MObjFPC -Scaghi -WR -Cirot -Os -gw2 -gl -vewnhibq -Filib\i386-win32
-Fu3rdparty\csvdocument -Fu3rdparty\fpspreadsheet -Fu. -FUlib\i386-win32

Linux bt shows (the location of the error seems weird - perhaps memory
messed up due to Firebird .so problems?)
(gdb) run
Starting program: /home/pascaldev/postcode/Source/dlldemo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff472d700 (LWP 7731)]
Starting dll demo program.
Looking up house number 68a, postcode 2514GL:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff785b8e5 in fpc_ansistr_decr_ref () from
(gdb) bt
#0  0x00007ffff785b8e5 in fpc_ansistr_decr_ref ()
   from /usr/lib/libdutchpostcode.so
#1  0x00007ffff7fe6b00 in ?? ()
#2  0x00007ffff785b975 in fpc_ansistr_assign ()
   from /usr/lib/libdutchpostcode.so
#3  0x0000000000000044 in ?? ()
#4  0x0000000000400770 in SetCity at plt ()
#5  0x0000000000000044 in ?? ()
#6  0x00007ffff78c33db in SETCITY (this=0x7ffff7fe6ac0,
    AVALUE=0x7ffff7fdf618 '''s-Gravenhage') at dutchaddress.pas:262
#7  0x00007ffff78bc22e in POSTCODE2ADDRESS (this=0x7ffff7fce960,
    ADDRESS=0x7ffff7fe6ac0) at businesslogic.pas:390
#8  0x00007ffff7851682 in POSTCODE2ADDRESS (NUMBER=0x474058 '68a',
    POSTCODE=0x474050 '2514GL') at dutchpostcode.lpr:153
#9  0x0000000000400d01 in main () at dlldemo.lpr:115

If I add cmem first in the .so uses clause, I get this on running my
dlldemo application:
Inconsistency detected by ld.so: dl-minimal.c: 136: realloc: Assertion
`ptr == alloc_last_block' failed!

Should I enable other options?
Longer term, I think this is a good reason to start PostgreSQL support
and check if that works.

Pointers/advice/requests for further info welcome, thanks.

More information about the fpc-pascal mailing list