Hi Daniel, could you please explain why you think this is a problem in base and not in libobjc2 or rather your code?
You are surely aware that the first call to printf("%p\n", NSMapGet(table, "xxx")); is actually the same as the later one with „yyy“? I don’t use libobjc2 myself, so I cannot test your code here. From just looking at your code I see you use NSPointerFunctionsWeakMemory for the values. I would expect that this requires the values to be ObjC objects, but you add the C string „asdasd“. Shouldn’t you be using @„asdasd“ here? This of course does not mean there could as well be a bug in NSConcreteMapTable, but you should try to provide better arguments to support this. I just tried to run your code on with Xcode on my Mac and there it fails with the expected error message inside of NSMapInsert. And I really tried this after writing the arguments above. Fred > Am 03.06.2017 um 21:30 schrieb Daniel Ferreira (theiostream) > <bnm...@gmail.com>: > > I believe I have found a bug trying out some basic behavior of > NSMapGet(). When running the following program (compiled with clang > and GNUstep's libobjc): > > --- > #import <Foundation/Foundation.h> > > int main() { > NSPointerFunctionsOptions keyOptions = > NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality; > NSPointerFunctionsOptions valueOptions = > NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality; > NSMapTable *table = [[NSMapTable alloc] > initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0]; > > printf("%p\n", NSMapGet(table, "xxx")); > NSMapInsert(table, "xxx", "asdasd"); > printf("%p\n", NSMapGet(table, "xxx")); > printf("%p\n", NSMapGet(table, "yyy")); > > return 0; > } > --- > > I get a segfault when trying to get a key that does not exist on the > map table (in this case, 'yyy'). > > Stacktrace: > > #0 objc_msgSend_fpret () at /root/gnustep/libobjc2/objc_msgSend.x86-64.S:130 > #1 0x00007ffff7bc5ba4 in autorelease (obj=0x4019df) at > /root/gnustep/libobjc2/arc.m:277 > #2 0x00007ffff7bc5fa3 in objc_autorelease (obj=0x4019df) at > /root/gnustep/libobjc2/arc.m:376 > #3 0x00007ffff7bc724d in objc_loadWeak (object=0x794b08) at > /root/gnustep/libobjc2/arc.m:693 > #4 0x00007ffff75af773 in pointerFunctionsRead (PF=<optimized out>, > addr=<optimized out>) at ././NSConcretePointerFunctions.h:105 > #5 GSIMapNodeForKeyInBucket (map=0x78cb20, bucket=0x794ac0, key=...) > at ../Headers/GNUstepBase/GSIMap.h:639 > #6 0x00007ffff75acc65 in GSIMapNodeForKey (map=0x78cb20, key=...) at > ../Headers/GNUstepBase/GSIMap.h:667 > #7 NSMapGet (table=0x78cb20, key=0x4019ea) at NSConcreteMapTable.m:591 > #8 0x00000000004009f2 in main () > > I tried investigating the issue and spent some hours trying to get the > internals of NSConcreteMapTable, but after some hours I could come to > no conclusion. Could anyone who played with this try to point me to a > fix? > > -- Daniel. > > _______________________________________________ > Gnustep-dev mailing list > Gnustep-dev@gnu.org > https://lists.gnu.org/mailman/listinfo/gnustep-dev _______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org https://lists.gnu.org/mailman/listinfo/gnustep-dev