diff mbox

=?UTF-8?Q?Fix=20for=20PR=20libobjc/47922=20("[4.6=20Regression]=20libobj?= =?UTF-8?Q?c=20crashes=20with=20garbage=20collection=20in=20any=20real-lif?= =?UTF-8?Q?e=20program")?=

Message ID 1298898537.48212483@www2.webmail.us
State New
Headers show

Commit Message

Nicola Pero Feb. 28, 2011, 1:08 p.m. UTC
Applied to trunk (4.6.0).

One problem we have is that we don't seem to have any testcases that test Objective-C
with the GNU Objective-C runtime and Garbage Collection enabled.  It would be good to
add these in 4.7 (hopefully at the same time we should also make the change to install
properly the GC library when GC is enabled!). ;-)

Thanks

Comments

Matthias Klose Feb. 28, 2011, 8:15 p.m. UTC | #1
On 28.02.2011 14:08, Nicola Pero wrote:
> It would be good to
> add these in 4.7 (hopefully at the same time we should also make the change to install
> properly the GC library when GC is enabled!). ;-)

why? it's built as a convenience library, and the object files are linked into
libobjc_gc.
Nicola Pero March 1, 2011, 12:40 a.m. UTC | #2
>> add these in 4.7 (hopefully at the same time we should also make the change to install
>> properly the GC library when GC is enabled!). ;-)
>
> why? it's built as a convenience library, and the object files are linked into
> libobjc_gc.

I had a problem with gnustep-base requiring the header gc/gc.h, which is not installed when I install
GCC.  The reason it requires it seems to be that the new trend is gnustep-base not using objc_malloc(),
but calling the GC library directly.  Higher-level libraries then use NSAllocateCollectable() & friends
to allocate memory, which is provided by gnustep-base.

Let me know if I'm missing something. ;-)

Thanks
Matthias Klose March 2, 2011, 1:49 a.m. UTC | #3
On 01.03.2011 01:40, Nicola Pero wrote:
> 
>>> add these in 4.7 (hopefully at the same time we should also make the change to install
>>> properly the GC library when GC is enabled!). ;-)
>>
>> why? it's built as a convenience library, and the object files are linked into
>> libobjc_gc.
> 
> I had a problem with gnustep-base requiring the header gc/gc.h, which is not installed when I install
> GCC.  The reason it requires it seems to be that the new trend is gnustep-base not using objc_malloc(),
> but calling the GC library directly.  Higher-level libraries then use NSAllocateCollectable() & friends
> to allocate memory, which is provided by gnustep-base.
> 
> Let me know if I'm missing something. ;-)

the other boehm-gc user in GCC is libjava, which doesn't require an installed gc
header.  Would it be sensible (if libobjc_gc is enabled) to install this header
in <gcc_lib_dir>/include/objc, so that it can be included as <objc/gc.h>?  That
way it wouldn't conflict with headers installed by a system wide libgc.

  Matthias
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 170559)
+++ ChangeLog   (working copy)
@@ -1,3 +1,9 @@ 
+2011-02-28  Richard Frith-Macdonald <rfm@gnu.org>
+
+       PR libobjc/47922
+       * gc.c (class_ivar_set_gcinvisible): Use _C_GCINVISIBLE instead of
+       a hardcoded "!".
+
 2011-02-13  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure: Regenerate.
Index: gc.c
===================================================================
--- gc.c        (revision 170559)
+++ gc.c        (working copy)
@@ -422,11 +422,15 @@ 
 
          /* The variable is gc visible so we make it gc_invisible.  */
          new_type = objc_malloc (strlen(ivar->ivar_type) + 2);
+
+         /* Copy the variable name.  */
          len = (type - ivar->ivar_type);
          memcpy (new_type, ivar->ivar_type, len);
-         new_type[len] = 0;
-         strcat (new_type, "!");
-         strcat (new_type, type);
+         /* Add '!'.  */
+         new_type[len++] = _C_GCINVISIBLE;
+         /* Copy the original types.  */
+         strcpy (new_type + len, type);
+
          ivar->ivar_type = new_type;
        }