View Issue Details

IDProjectCategoryView StatusLast Update
0003645JEDI VCL00 JVCL Componentspublic2006-04-19 05:35
ReporterAriochAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformJVCL post-3.1 CVS, Delphi 5OSwin 2000OS Version
Product Version3.10 
Target VersionFixed in Version3.30 
Summary0003645: TJvThread.Execute - may lead to inconsistent state
DescriptionAssume that TJvThread.Exclusive is set to TRUE.


----- quote from TJvThread.Execute ----
  if Assigned(FOnExecute) then
  begin
    Inc(FThreadCount);
---------------------------------------

What if some Exception would be thrown hereafter ?
There are 3 lines that potentially can cause it.

1: BaseThread := TJvBaseThread.Create(Self, FOnExecute, P);
2: FThreads.Add(BaseThread);
3: DoCreate;

Then thread is not created/started but FThreadCount is not reverted (decremented).
So, any later call to .Execute would just quit because of
----------
  if Exclusive and OneThreadIsRunning then
    Exit;
----------

There is no single thread running, but .OneThreadIsRunning claims it is!
Steps To Reproducedrop TJvThread onto form,
set .Exclusive to true,
set .OnBegin event that would 1) JvThread1.OnBegin := nil; 2) Abort; (* or throw any other Exception to cancel thread launching *)
set .OnExecute event that would, say, change form's caption or somehow else display that thread was executed


drop TButton that would try to execute the thread.

2nd, 3rd, etc pressing of Button1 should make thread running - but it would not.
TagsNo tags attached.

Activities

Arioch

2006-04-18 17:43

developer   ~0009136

To add: OneThreadIsRunning is bad name, it confuses do we mean 'AtLeastOne' or 'ExactlyOne'
It is better to be renamed to SomeThreadIsRunning

What is the sense there to have an extra FThreadCount when we already do have FThread.Count.
Speed can't be the reason, since we heavily use, for example, FThread[i] even for .Exclusive jvthreads.

obones

2006-04-19 05:35

administrator   ~0009142

This has now been changed in SVN

Issue History

Date Modified Username Field Change
2006-04-18 16:54 Arioch New Issue
2006-04-18 17:43 Arioch Note Added: 0009136
2006-04-19 05:35 obones Status new => resolved
2006-04-19 05:35 obones Resolution open => fixed
2006-04-19 05:35 obones Assigned To => obones
2006-04-19 05:35 obones Note Added: 0009142