Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Save Desktop    [ Add a report in this area ]  
Report #:  61289   Status: Closed
Improper use of TThead.Suspend in LoadDesktop
Project:  Delphi Build #:  11.0.2902.10471
Version:    11.2 Submitted By:   Sebastian Zierer
Report Type:  Crash / Data loss / Total failure Date Reported:  4/22/2008 11:08:28 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   259621
Resolution: Fixed (Resolution Comments) Resolved in Build: : 12.0.3136.15942
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 10
Description
When trying to debug a program Delphi came up with an exception in Thread.Suspend. I was surprised to find that call in the call stack of LoadDesktop because when using that function you'll very likely run into deadlocks and access violations. Please use a proper synchronisation object instead of SuspendThread.

Apart from the warnings in the Platform SDK:
If the thread that is to be suspended happens to be suspended while using the heap, you will deadlock. Remember that the heap is a threadsafe object. In that case the thread might own a critical section or another synchronization object.

2003f2d3 +03f rtl100.bpl         Classes     10236  +5 Classes.TThread.Suspend
209df443 +01b coreide100.bpl     Desktop      1493  +1 Desktop.TDesktopStates.LoadDesktop
209df5c4 +06c coreide100.bpl     Desktop      1553  +9 Desktop.TDesktopStates.LoadRuntimeDesktop
209df756 +03a coreide100.bpl     Desktop      1582  +4 Desktop.TDesktopStates.ProcessCreated

I'm sure that this will be the reason for a deadlock in the IDE.

Windows SDK:
This function is primarily designed for use by debuggers. It is not intended to be used for thread synchronization. Calling SuspendThread on a thread that owns a synchronization object, such as a mutex or critical section, can lead to a deadlock if the calling thread tries to obtain a synchronization object owned by a suspended thread.
Steps to Reproduce:
Attach a debugger to the IDE, set a breakpoing in TThread.Suspend. Then switch the IDE Desktop or start debugging a program. TThread.Suspend should not be called.
Workarounds
None
Attachment
None
Comments

Markus Humm at 4/22/2008 11:17:39 PM -
Marked as needs attention

Server Response from: ETNACODE01