ne0bot / delphionrails

Automatically exported from code.google.com/p/delphionrails
0 stars 0 forks source link

r179 - TThread.Suspend and TThread.Resume aren't deprecated only, but seriously broken #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In our application, we stumbled across serious connection issues after updating 
DOR (client sends a HTTP GET, but the server answers with a rude TCP RST and 
ProcessRequest routines won't even catch the GET). We could isolate the error 
to the dorSocketStub.pas changes in r179 (using TThread instead of Windows API).

Some research shows that ignoring the deprecated warning for TThread.Suspend 
and TThread.Resume is fatal - using these can lead to freed memory being used, 
especially for applications using many threads. See 
http://qc.embarcadero.com/wc/qcmain.aspx?d=26291 for an official bug, 
http://stackoverflow.com/questions/1418333/tthread-resume-is-deprecated-in-delph
i-2010-what-should-be-used-in-place for a more broad discussion.

Also, from http://docwiki.embarcadero.com/VCL/en/Classes.TThread.Suspend:

"Warning: The Resume and Suspend methods should only be used for debugging 
purposes. Suspending a thread using Suspend can lead to deadlocks and undefined 
behavior within your application. Proper thread synchronization techniques 
should be based on TEvent and TMutex."

Original issue reported on code.google.com by schnaade...@gmail.com on 16 Mar 2012 at 12:53

GoogleCodeExporter commented 8 years ago
A possible workaround (until this issue is solved) that works for us is to use 
the older version of dorSocketStub.pas, applying only the CurrentThread -> 
CurrentDorThread changes and changing dorService.pas to use FThreads.Pause 
instead of FThreads.Suspend again.

After this, r217 can be applied to be as close as possible to the current state.

Original comment by schnaade...@gmail.com on 16 Mar 2012 at 1:05

GoogleCodeExporter commented 8 years ago
http://stackoverflow.com/questions/2097316/with-what-delphi-code-should-i-replac
e-my-calls-to-deprecated-tthread-method-sus is a follow-up question to the 
question posted above and contains several suggestions what to use instead of 
TThread as well as a replacement class for TThread.

Original comment by schnaade...@gmail.com on 11 Apr 2012 at 1:28