[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in base: NSMapGet()
From: |
Daniel Ferreira (theiostream) |
Subject: |
Bug in base: NSMapGet() |
Date: |
Sat, 3 Jun 2017 16:30:33 -0300 |
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.
- Bug in base: NSMapGet(),
Daniel Ferreira (theiostream) <=