Patchwork Fix for PR libobjc/47012

login
register
mail settings
Submitter Nicola Pero
Date Dec. 19, 2010, 7:13 p.m.
Message ID <1292786027.994926656@192.168.2.227>
Download mbox | patch
Permalink /patch/76152/
State New
Headers show

Comments

Nicola Pero - Dec. 19, 2010, 7:13 p.m.
This patch fixes libobjc/47012.  See the bug discussion for more info.

Committed to trunk.

Thanks

Patch

Index: accessors.m
===================================================================
--- accessors.m (revision 168068)
+++ accessors.m (working copy)
@@ -106,8 +106,18 @@ 
     {
       id *pointer_to_ivar = (id *)((char *)self + offset);
 
+
       if (is_atomic == NO)
-       return AUTORELEASE (RETAIN (*pointer_to_ivar));
+       {
+         /* Note that in this case, we do not RETAIN/AUTORELEASE the
+            returned value.  The programmer should do it if it is
+            needed.  Since access is non-atomic, other threads can be
+            ignored and the caller has full control of what happens
+            to the object and whether it needs to be RETAINed or not,
+            so it makes sense to leave the decision to him/her.  This
+            is also what the Apple/NeXT runtime does.  */
+         return *pointer_to_ivar;
+       }
       else
        {
          objc_mutex_t lock = accessors_locks[ACCESSORS_HASH (pointer_to_ivar)];
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 168068)
+++ ChangeLog   (working copy)
@@ -1,5 +1,11 @@ 
 2010-12-19  Nicola Pero  <nicola.pero@meta-innovation.com>
 
+       PR libobjc/47012
+       * accessors.m (objc_getProperty): If not atomic, do not
+       retain/autorelease the returned value. (Problem reported by
+
+2010-12-19  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        * objc-private/runtime.h (__objc_selector_max_index,
        __objc_init_selector_tables, __objc_register_selectors_from_class,
        __objc_register_selectors_from_list,