worth a shot, but for whatever reason, we seem to experience 
heap-use-after-free segfaults when using weak references under ARC in the 
current libobjc2 runtime.  

I replace the following functions with their reference implementations below, 
and it seems to solve our seg-fault issues using weak references under arc:

https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-initweak
 
<https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-initweak>

objc_copyWeak
objc_destroyWeak
objc_initWeak
objc_loadWeak


-Jordan


> On Jul 29, 2019, at 8:38 AM, Frederik Seiffert <[email protected]> 
> wrote:
> 
> Hi,
> 
> I’m trying to use an NSHashTable with weak objects (-weakObjectsHashTable) on 
> Android, but it’s segfaulting in addObject: on all architectures (ARM/x86). 
> Does anyone know if this should be supported or what might be going on here?
> 
> Following is the backtrace:
> 
>     frame #5: 0xca4e2b12 libobjc.so`objc_msgSend at objc_msgSend.x86-32.S:120
>     frame #6: 0xc9befbcd libgnustep-base.so`hashObject(item=0xcacce5a0, 
> size=0x00000000) at NSConcretePointerFunctions.m:126
>     frame #7: 0xc9b02992 
> libgnustep-base.so`pointerFunctionsHash(PF=0xc7d2d210, item=0xcacce5a0) at 
> NSConcretePointerFunctions.h:180
>     frame #8: 0xc9aff7b6 
> libgnustep-base.so`GSIMapBucketForKey(map=0xc7d2d1e4, key=GSIMapKey @ 
> 0xfff875b4) at GSIMap.h:410
>     frame #9: 0xc9b02c03 
> libgnustep-base.so`GSIMapAddNodeToMap(map=0xc7d2d1e4, node=0xcacce590) at 
> GSIMap.h:453
>     frame #10: 0xc9afe964 libgnustep-base.so`GSIMapAddKey(map=0xc7d2d1e4, 
> key=GSIMapKey @ 0xfff87644) at GSIMap.h:1118
>     frame #11: 0xc9b0074f libgnustep-base.so`-[NSConcreteHashTable 
> addObject:](self=0xc7d2d1e4, _cmd="C", anObject=0xcac9945c) at 
> NSConcreteHashTable.m:863
> 
> 
> Interestingly, when I use hashTableWithWeakObjects 
> (NSPointerFunctionsZeroingWeakMemory, deprecated on Apple platforms) instead 
> of weakObjectsHashTable (NSPointerFunctionsWeakMemory), addObject: works OK, 
> but the pointer is not zero’d when the object is released.
> 
> Thanks!
> Frederik
> 
> _______________________________________________
> Discuss-gnustep mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep

_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to