View Issue Details

IDProjectCategoryView StatusLast Update
0035304FPCRTLpublic2019-04-01 19:31
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target Version3.2.0Fixed in Version3.3.1 
Summary0035304: RegisterClassAlias is not thread-safe
DescriptionRegisterClassAlias is not thread-safe, as RegisterClasses and GetClass is.

RegisterClassAlias must use the same lock as GetClass uses (ClassList.LockList).
Additional InformationPatch attached.
TagsNo tags attached.
Fixed in Revision41818
FPCOldBugId
FPCTarget
Attached Files
  • RegisterClassAlias-01.patch (610 bytes)
    Index: rtl/objpas/classes/cregist.inc
    ===================================================================
    --- rtl/objpas/classes/cregist.inc	(revision 41802)
    +++ rtl/objpas/classes/cregist.inc	(working copy)
    @@ -44,9 +44,14 @@
       var
         I : integer;
       begin
    -    i := ClassAliasList.IndexOf(Alias);
    -    if I = -1 then
    -      ClassAliasList.AddObject( Alias, TObject(AClass) );
    +    ClassList.LockList;
    +    try
    +      i := ClassAliasList.IndexOf(Alias);
    +      if I = -1 then
    +        ClassAliasList.AddObject( Alias, TObject(AClass) );
    +    finally
    +      ClassList.UnlockList;
    +    end;
       end;
     
     
    

Activities

Ondrej Pokorny

2019-04-01 16:32

reporter  

RegisterClassAlias-01.patch (610 bytes)
Index: rtl/objpas/classes/cregist.inc
===================================================================
--- rtl/objpas/classes/cregist.inc	(revision 41802)
+++ rtl/objpas/classes/cregist.inc	(working copy)
@@ -44,9 +44,14 @@
   var
     I : integer;
   begin
-    i := ClassAliasList.IndexOf(Alias);
-    if I = -1 then
-      ClassAliasList.AddObject( Alias, TObject(AClass) );
+    ClassList.LockList;
+    try
+      i := ClassAliasList.IndexOf(Alias);
+      if I = -1 then
+        ClassAliasList.AddObject( Alias, TObject(AClass) );
+    finally
+      ClassList.UnlockList;
+    end;
   end;
 
 

Michael Van Canneyt

2019-04-01 19:25

administrator   ~0115170

Thanks for the patch. Checked and applied !

Ondrej Pokorny

2019-04-01 19:31

reporter   ~0115171

Thank you!

Issue History

Date Modified Username Field Change
2019-04-01 16:32 Ondrej Pokorny New Issue
2019-04-01 16:32 Ondrej Pokorny File Added: RegisterClassAlias-01.patch
2019-04-01 17:00 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-04-01 17:00 Michael Van Canneyt Status new => assigned
2019-04-01 19:25 Michael Van Canneyt Fixed in Revision => 41818
2019-04-01 19:25 Michael Van Canneyt Note Added: 0115170
2019-04-01 19:25 Michael Van Canneyt Status assigned => resolved
2019-04-01 19:25 Michael Van Canneyt Fixed in Version => 3.3.1
2019-04-01 19:25 Michael Van Canneyt Resolution open => fixed
2019-04-01 19:25 Michael Van Canneyt Target Version => 3.2.0
2019-04-01 19:31 Ondrej Pokorny Note Added: 0115171
2019-04-01 19:31 Ondrej Pokorny Status resolved => closed