I have some very old code that could successfully call a function in C dll, and I have old executable that confirms that compiled application still works on my current system where dll is. However, that application doesn't work when the same project is compiled with FPC 3.2.1 and Lazarus 2.0.11. Well, it works if I do not use just one single function from that dll. Using that single function causes 'External: SIGSEGV' exception at address 655065E2. Both old and new IDE and DLL are 32bit, problem shows also without running code from IDE, clean up and build all did not help, switching off all optimization did not help, current testing OS is Win10x64, and all tested functions from dll wrapper work fine except that one. This is pascal wrapper for the problematic function:
function pilg_getconnectedserver(servernamebuf: pchar; var bufsize: longint; var NodeID: longint; var port: longint; seq: longint): longint; stdcall; external 'pilog32.dll';
and this is what it looks in C:
EXPORTPIINT32 pilg_getconnectedserver
(
char PIPTR* lpszServerNameBuf, // server name buffer
int32 PIPTR* plBufSize, // buffer size - in/out
int32 PIPTR* plNodeId, // node id
int32 PIPTR* plPort, // port number
int32 lSeq // sequence GETFIRST, GETNEXT
);
with some more details here:
https://techsupport.osisoft.com/Documentation/PI-SDK/PI-API/Functions/pilg_getconnectedserver.htm.
That function worked well when compiled with old FPC SVN 05-07-2013 Rev 25050 and Lazarus SVN 05-07-2013 Rev 42002. It also works well when compiled with even older IDE from 2010.
Since that single function is kind of important detail (there is no other way to get the list of connected servers), I will try to fix the problem since I have to revisit the project. I have some ideas which I do not like too much, so before digging deeper I am asking for your suggestions in a hope to hear something that could help me. All comments are welcome, and at this stage I am open to all ideas.