Comments (8)
If you using code from #158 you can replace (straight forward solution)
return(((uintptr_t)objectPtr) >> 60);
with
if (@available(iOS 14, *)) {
return(((uintptr_t)objectPtr) & 0x7);
} else {
return(((uintptr_t)objectPtr) >> 60);
}
if you using code from master branch you will need to update isa usage
patch.diff
diff --git a/JSONKit.m b/JSONKit.m
index 0e9331f..c47ab02 100644
--- a/JSONKit.m
+++ b/JSONKit.m
@@ -677,7 +677,7 @@ static JKArray *_JKArrayCreate(id *objects, NSUInteger count, BOOL mutableCollec
NSCParameterAssert((objects != NULL) && (_JKArrayClass != NULL) && (_JKArrayInstanceSize > 0UL));
JKArray *array = NULL;
if(JK_EXPECT_T((array = (JKArray *)calloc(1UL, _JKArrayInstanceSize)) != NULL)) { // Directly allocate the JKArray instance via calloc.
- array->isa = _JKArrayClass;
+ object_setClass(array, _JKArrayClass);
if((array = [array init]) == NULL) { return(NULL); }
array->capacity = count;
array->count = count;
@@ -928,7 +928,7 @@ static JKDictionary *_JKDictionaryCreate(id *keys, NSUInteger *keyHashes, id *ob
NSCParameterAssert((keys != NULL) && (keyHashes != NULL) && (objects != NULL) && (_JKDictionaryClass != NULL) && (_JKDictionaryInstanceSize > 0UL));
JKDictionary *dictionary = NULL;
if(JK_EXPECT_T((dictionary = (JKDictionary *)calloc(1UL, _JKDictionaryInstanceSize)) != NULL)) { // Directly allocate the JKDictionary instance via calloc.
- dictionary->isa = _JKDictionaryClass;
+ object_setClass(dictionary, _JKDictionaryClass);
if((dictionary = [dictionary init]) == NULL) { return(NULL); }
dictionary->capacity = _JKDictionaryCapacityForCount(count);
dictionary->count = 0UL;
@@ -2596,7 +2596,7 @@ static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *object
BOOL workAroundMacOSXABIBreakingBug = (JK_EXPECT_F(((NSUInteger)object) & 0x1)) ? YES : NO;
- void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : *((void **)objectPtr);
+ void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : ((void *)object_getClass(objectPtr));
if(JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) { goto slowClassLookup; }
if(JK_EXPECT_T(objectISA == encodeState->fastClassLookup.stringClass)) { isClass = JKClassString; }
@@ -2792,7 +2792,7 @@ static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *object
for(id keyObject in enumerateObject) {
if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } }
printComma = 1;
- void *keyObjectISA = *((void **)keyObject);
+ void *keyObjectISA = (void *)object_getClass(keyObject);
if(JK_EXPECT_F((keyObjectISA != encodeState->fastClassLookup.stringClass)) && JK_EXPECT_F(([keyObject isKindOfClass:[NSString class]] == NO))) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }
if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, keyObject))) { return(1); }
if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ":"))) { return(1); }
@@ -2804,7 +2804,7 @@ static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *object
for(idx = 0L; idx < dictionaryCount; idx++) {
if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } }
printComma = 1;
- void *keyObjectISA = *((void **)keys[idx]);
+ void *keyObjectISA = (void *)object_getClass(keys[idx]);
if(JK_EXPECT_F(keyObjectISA != encodeState->fastClassLookup.stringClass) && JK_EXPECT_F([(id)keys[idx] isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }
if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, keys[idx]))) { return(1); }
if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ":"))) { return(1); }
however there was comment not to use object_getClass
due to performance impact, but goal was to fix the crashes.
P.S. Did not test this deeply, but seems to be working...
from jsonkit.
If you using code from #158 you can replace (straight forward solution)
return(((uintptr_t)objectPtr) >> 60);with
if (@available(iOS 14, *)) { return(((uintptr_t)objectPtr) & 0x7); } else { return(((uintptr_t)objectPtr) >> 60); }if you using code from master branch you will need to update isa usage
patch.diff
however there was comment not to useobject_getClass
due to performance impact, but goal was to fix the crashes.P.S. Did not test this deeply, but seems to be working...
it's work for me
from jsonkit.
I'm having this issue too. Is there any workaround?
from jsonkit.
I'm having this issue too. Exist any alternative for this error.?
from jsonkit.
I'm having this issue too.
from jsonkit.
NSNumber 类型数据都有问题,换成NSString类型就没有问题
from jsonkit.
I have fixed #158 for new format of tagged pointers in macOS on Apple Silicon and last versions of iOS, watchOS and tvOS. Also replaced isa dereference by fast class lookup.
Please comment if it is not working for you…
from jsonkit.
For people curious to compare #158 and NSJSON, see JSONKitTest.
from jsonkit.
Related Issues (20)
- Any popular replacement for JSONKit? HOT 2
- BSD two-clause or three-clause license? HOT 2
- crash at JSONKit.m:2598:77 HOT 2
- Error in serializing NSNumber HOT 2
- Supporting gzip decompression
- Swift HOT 7
- can not use with xcode 7 HOT 4
- Xcode 7 Before is use JSONKit in Object but now not use JSONKit in Xcode 7 HOT 7
- crash with iOS9 Xcode7 HOT 5
- Should be #import <JSONKit/JSONKit.h> or <GCJSONKit/JSONKit.h>? HOT 1
- please ignore
- Crash when NSDictionary to String json format. HOT 1
- about convert json to NSDictioanry (error if json string contains double field) HOT 7
- JsonKit message JSONDataWithOptions crashes in macOS Sierra HOT 1
- JSONKit Installation error in X-code 7.3.1 iOS 9.3 HOT 1
- iOS TRAP_TRACE crash
- JSONKit semantic issue after updating the pod HOT 3
- @serkrapiv Not necessarily verboten, just that they must be escaped. The first paragraph of 2.5 Strings says: HOT 1
- Yea
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonkit.