[fpc-pascal] fix for GetLastError/WSAGetLastError with threads under windows [was WSAGetLastError returns 0 when it shouldn't but I cannot see why]

Luca Olivetti luca at ventoso.org
Tue Mar 18 09:30:46 CET 2008


En/na Luca Olivetti ha escrit:
> El Thu, 06 Mar 2008 13:09:34 +0100
> "Lukas Gebauer" <gebylist at mlp.cz> escribió:
> 
> 
>> It is IMHO bug in FPC, just because Synapse code working in 
>> Delphi/Kylix threads perfectly. It have a problem on FPC threads 
>> only, and as I see in this discussion, problem have other programs 
>> too, not just Synapse. And I am pretty sure, Synapse working fine 
>> with some older FPC versions.
> 
> And it also works fine with fpc under linux. That's why I wrote "fix"
> in quotes, since I don't think that synapse is doing anything wrong.
> Anyway, since I need/want to use synapse (actually I don't want to
> write my own  ftp client, the one in synapse works just fine), while
> the compiler gurus find the cause of the problem, I worked around it in
> SockCheck by assigning a dummy code to FLastError if
> synsock.WSAGetLastError returns 0.
> I'm still worried of other side effects in windows TThread code.

Jonas Maebe found the cause of the bug: when you use threads under 
windows, there are calls to TlsGetValue (made in SysRelocateThreadVar) 
to keep track of exception frames, and TlsGetValue reset LastError to 0.
If some windows developer is listening, please take a look at the patch 
I posted on the bug report:

http://bugs.freepascal.org/view.php?id=10205

Bye
-- 
Luca




More information about the fpc-pascal mailing list