[Lazarus] WinINet STDCALL callback crash

Ludo Brands ludo.brands at free.fr
Thu Mar 14 08:51:03 CET 2013


On 03/14/2013 12:09 AM, Benito van der Zander wrote:
>> However, I still get frequent, random segfaults when calling Windows
>> functions.  My current attempt, as simple as I can make it, is below. 
>> About 50% of the time, the first command in the execute procedure
>> works fine; the other times it causes a crash.
> An actually crash or just a segfault message in the debugger?
> 
> I have been using wininet in a similar way for years, and it throws an
> error quite often, when run from within Lazarus.
> But when called normally, without Lazarus everything works fine.
> I think wininet and debuggers just do not play well together...
> 
> 

Or is it a SIGFPE? There are known similar problems with FPC and dll's
crashing with floating point errors. With SetExceptionMask (unit math)
you can mask these exceptions.

If you run on Win64 then SEH can cause crashes with dll's. Latest FPC
from trunk (2.7.1) enables SEH on win64 by default.

Why don't you use a sync library such as synapse
(http://synapse.ararat.cz/doku.php) in your thread? In httpsend you'll find
function HttpGetBinary(const URL: string; const Response: TStream): Boolean;
Create a FileStream, call HttpGetBinary and close the stream, done. No
external dependencies.

Also don't change FileMode in a thread. FileMode is global. This is not
the cause of the crash you are seeing but could cause weird problems
later on.

Ludo




More information about the Lazarus mailing list