JSONKit icon indicating copy to clipboard operation
JSONKit copied to clipboard

crash on 10.10 yosemite and Xcode 6 dp4

Open V01dZer0 opened this issue 10 years ago • 6 comments

screen shot 2014-08-01 at 3 16 20 pm

V01dZer0 avatar Aug 01 '14 07:08 V01dZer0

i get the same error when i try to do encode Dictionary to JSON string. iOS 8.0

yoon-boom avatar Oct 07 '14 00:10 yoon-boom

I also got the error too, running on Mac OSX Yosemite with the same case as @yoon-boom

0xd01 avatar Oct 21 '14 08:10 0xd01

This change worked for me...

---from--- void keyObjectISA = *((void *)keys[idx]); ---to--- void* key = keys[idx]; void* keyObjectISA = key; ---or--- void* keyObjectISA = keys[idx]; // should work as well

richrice avatar Oct 24 '14 18:10 richrice

This is due to the recent addition of NSTaggedPointerString, which allows inline storage of strings within the pointer value. Thus a short string, like @"email" gets strored inline within a pointer value like 0x0000656D61696C55. Depending on your application memory usage, this value might or might not point to a valid memory location. More, due to the double indirection in the problematic line, the chances of getting to an invalid memory location are quite high, resulting in crashes.

What JSONKit tries to do at that line is to retrieve the Class object for the given key, and for performance reasons it tries to directly access the "isa" pointer. The fix would be to use runtime's object_getClass() function, instead of using the direct access:

void *keyObjectISA = (void*)object_getClass(keys[idx]);

cristiankocza-sv avatar Nov 11 '14 08:11 cristiankocza-sv

Fixed in #158.

jcbertin avatar Nov 13 '14 16:11 jcbertin

@jcbertin I faced this problem, your fix fixed the problem for me.

haxpor avatar Feb 28 '16 05:02 haxpor