Giter Site home page Giter Site logo

Comments (15)

johnezang avatar johnezang commented on May 14, 2024

The NSInternalInconsistencyException exception message is clearly generated by JSONKit- JSONKit has detected a condition which, if things are working correctly, "should not happen". Because the assertion check has multiple conditions that it checks, it's hard to tell exactly which one of the checks failed. If I had to guess, the most likely would be objects[objectIndex] != NULL, which would translate in to prose "The array in question should have a valid object at this index, but for some unexpected reason it is NULL".

If you could, could you please add to this bug report the JSON that was used / parsed that is causing this problem? Hopefully that will be enough for me to determine where things went wrong inside JSONKit and put together a fix for you. If it's not, I may need a bit more information from you.

Also, are the arrays and dictionary in question mutable? And if so, are you performing mutating operations on them, such as adding or removing items?

And since you are using a tableview, are you using a NSArrayController and/or bindings to display the contents of the array?

from jsonkit.

johnezang avatar johnezang commented on May 14, 2024

Also, could add the following just before line 745, where the NSAssertion is:

  if(!((objects != NULL) && (count <= capacity) && (objects[objectIndex] != NULL))) {
    NSLog(@"objects: %p", objects);
    NSLog(@"count: %ld, capacity: %ld", count, capacity);
    NSLog(@"objectIndex: %ld, objects[objectIndex]: %p", objectIndex, (objects != NULL) ? objects[objectIndex] : NULL);
  }
  NSParameterAssert((objects != NULL) && (count <= capacity) && (objects[objectIndex] != NULL)); // Line 745

Then, run your app, and when the condition that causes the NSAssertion to fail, it should print out a bunch of info to the console that will help determine exactly what has gone wrong.

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

Thanks so much for the response, I really appreciate it! everything else seems great so far and i picked JSONkit for the performance. Ill get the info you asked for and reply in a bit. thanks again!!

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

ok i was able to hover over the variables in the three part assertion...count shows as 25 as does capacity so okay there. you're right, objects might be the issue. hovering over it shows "id * objects 0x0" - where does this come from? NSloging shows me I have data in the arrays and dictionaries.

not sure if i can provide JSON itself, but i can work on creating dummy one that exactly mimics it with fake data

no mutable arrays or dictionaries.

not using nsarraycontroller, should i be?

i'll add the if you sent and run and send results next. thanks!!

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

heres from the console, looks like objects is empty?

2011-05-27 15:52:25.272 navtest2[27134:207] objects: 0x0
2011-05-27 15:52:25.273 navtest2[27134:207] count: 25, capacity: 25
2011-05-27 15:52:25.273 navtest2[27134:207] objectIndex: 0, objects[objectIndex]: 0x0

from jsonkit.

johnezang avatar johnezang commented on May 14, 2024

That's very odd. objects is the JKArray (an internal JSONKit class) iVar that holds the pointer to the memory allocation where the objects in that array are kept. There are very few things that modify that variable- when the array is created, sometimes when it is mutated and needs to grow that allocation, and when the object is released. This makes me wonder if you might have accidently released the object but still have a reference to it. Can you try making the following modification (near line 717):

- (void)dealloc
{
  if(JK_EXPECT_T(objects != NULL)) {
    NSUInteger atObject = 0UL;
    for(atObject = 0UL; atObject < count; atObject++) { if(JK_EXPECT_T(objects[atObject] != NULL)) { CFRelease(objects[atObject]); objects[atObject] = NULL; } }
    free(objects); objects = (void *)0xbadc0de; // Change from NULL to (void *)0xbadc0de.
  }

  [super dealloc];
}

Also change line ~745, the same NSAssertion that you originally reported, to the following:

  NSParameterAssert((objects != NULL) && (objects != (void *)0xbadc0de) && (count <= capacity) && (objects[objectIndex] != NULL));

This will allow the assertion to catch the fact that objects is set to 0xbadcode instead of allowing it to pass through and cause a sig fault or something.

My suspicion is that you will make these changes, and objects will be set to 0xbadcode, and the only way that could happen is because you missed a -retain somewhere.

from jsonkit.

johnezang avatar johnezang commented on May 14, 2024

Assuming that my hunch that this is a retain / release issue, you might want to take a look at enabling NSZombieEnabled. You can find information about how to enable it here.

Some more memory debugging links:

http://www.cocoadev.com/index.pl?NSZombieEnabled
http://developer.apple.com/library/mac/#technotes/tn2004/tn2124.html
http://developer.apple.com/library/mac/technotes/tn2004/tn2124.html#SECFOUNDATION

from jsonkit.

johnezang avatar johnezang commented on May 14, 2024

@skinsfan00atg, any update on this issue? Did it end up being a retain / release problem, or do we still need to dig in to a possible problem with JSONKit?

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

Sorry had family visiting will try tonight, thanks again!

On May 30, 2011, at 4:57 AM, [email protected] wrote:

@skinsfan00atg, any update on this issue? Did it end up being a retain / release problem, or do we still need to dig in to a possible problem with JSONKit?

Reply to this email directly or view it on GitHub:
#27 (comment)

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

so sorry for the delay, it was a self. issue and now everything works great!

from jsonkit.

BenHall avatar BenHall commented on May 14, 2024

Sorry to raise this again, but what do you mean by a self. issue? I'm experiencing the same problem.

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

I'll double check my resolution when I get back to my work computer tomorrow

On Nov 1, 2011, at 7:28 PM, Ben [email protected] wrote:

Sorry to raise this again, but what do you mean by a self. issue? I'm experiencing the same problem.

Reply to this email directly or view it on GitHub:
#27 (comment)

from jsonkit.

DavidBoyes avatar DavidBoyes commented on May 14, 2024

I had the same problem, it was a retain/release problem for me.

from jsonkit.

adambemowski avatar adambemowski commented on May 14, 2024

Had the same issue, I was trying to set the output straight to a dictionary I had created.
myDictionary = [string objectFromJSONString];

solved it by setting the output to a temporary dictionary and making a copy
NSDictionary *tempDictionary =[string objectFromJSONString];
myDictionary = [tempDictionary copy];

JSONKit is a very nice tool I will continue to use it!

from jsonkit.

andrewtgraydc avatar andrewtgraydc commented on May 14, 2024

BenHall, did you ever fix yours?

from jsonkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.