Hello Maik,

My assumption is that you have discovered a (Win32 specific) FreePascal bug!

I had a similar issue when writing FreePascal in a *callback* of a Mac OS X libary that is called in an *non-FreePascal* thread - the reason for that crash is that the FPC runtime is not correctly initialized at the time of the callback. Jonas fixed this for Mac OS X in FreePascal revision 15557 (SVN).

At the end of that thread I asked the question there if this issue does exist for the Windows (Win32/64) target too (and if so, maybe there is already a fix for this?) - Maybe we both get an answer here of the Win32 maintainer now :-)

Here's the old thread:
http://www.mail-archive.com/[email protected]/msg21101.html

There's a FPC test for the non-FPC callback bug (for non-Win32 targets only):
http://svn.freepascal.org/svn/fpc/trunk/tests/test/textthr.pp


Regards,
Alexander



Maik Wojcieszak schrieb:
Hi,

I'm working on a port of a Delphi component to Lazarus. The component wraps a dll for Network Communication based on ASPLs Vortex Library but implementing a full set of "easy to use" mechanisms for "daily work problems".

The dll itself is written in C++ with a C like interface. It is multithreaded and uses callbacks for a lot of purposes.
The callback function/procedure is defined like

//#---------------------------------------------------------------------
//                     CALLBACK PROCEDURES
//#---------------------------------------------------------------------
procedure ExecuteCommandClb(tmlhandle : TML_COMMAND_HANDLE; pCBData : Pointer); cdecl;
begin
 //...
end;

No matter what I do inside this procedure if I reach the end the assembler window is popping up in the debugger.
The Parameters seem to be correct.

pCBData is a Pointer to an object stored with the pointer to the callback. The procedure is used as a proxy to call
the real worker method of the object.

tmlhandle is also a Pointer, but to an object that is implemented in the dll.

The callback procedure is set like tml_Profile_Register_Cmd(FTMLCoreHandle, PCHAR(profile), cmd.CommandId, @ExecuteCommandClb, Pointer(cmd));

This command stores the inside the dlls for callbacks.

I've set the user flag -dUseCThreads in the package and it is inherited to my project.

No matter what I do inside the ExecuteCommandClb my application will crash after some calls. The Parameters seem to be correct
because for some calls they will be used correctly.

Alle this code and the dlls are tested and work stable with Delphi. That's why I hope somebody can tell me
if it is a Lazarus/FPC problem and how to solve it.

Thanks in advance
Connor

My Versions:

Lazarus IDE v0.9.28.2 Beta
MS Windows XP Prof DE sp3
FPC Version 2.2.4





--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to