discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSHashTable with weak objects crashing


From: Jordan Schidlowsky
Subject: Re: NSHashTable with weak objects crashing
Date: Mon, 29 Jul 2019 22:55:55 -0600

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

objc_copyWeak
objc_destroyWeak
objc_initWeak
objc_loadWeak


-Jordan


On Jul 29, 2019, at 8:38 AM, Frederik Seiffert <frederik@algoriddim.com> 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
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep


reply via email to

[Prev in Thread] Current Thread [Next in Thread]