Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6116817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:15:00+00:00 2026-05-23T15:15:00+00:00

Am using an NSMutableSet that is working great, up until this weird SIGABRT error

  • 0

Am using an NSMutableSet that is working great, up until this weird SIGABRT error popped up:

2011-07-05 17:01:00.249 Dama[1497:cd57] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFSet removeObject:]: attempt to remove nil’

ok, I can’t remove nil, but here is my code:

    id item = nil;
if ([theSet count] == 0) { // This equals 1 !!
    item = [[[self getClass] alloc] init];
} else {
    item = [[theSet anyObject] retain]; //this returns nil !!
    [theSet removeObject:item]; // ERROR !!
}

Using gdb console, I found theSet looks like this:

(gdb) po theSet

{(

 (null)

)}

(gdb) print (int) [theSet count]

$1 = 1

How is this even possible?

P.S.: Am running in a multi-threaded environment .. I can’t promise that the isn’t being accessed by two threads at the same time, but it shouldn’t be the case..

EDIT

Please, I really want to know how can the NSSet end up with (null), I dont care how it got there .. No matter how dirty my multi-threaded program is, This shouldn’t happen, I think. [And I double checked, this set is only accessed by the background worker thread].

EDIT

2011-07-05 17:39:55.884 App[1608:c59f] Set count = 2
Contains: {(

< Step: 0xc43f3e0>,
< Step: 0x62f1800> )} 

2011-07-05 17:39:55.886
App[1608:c59f] Set count = 9 Contains: {(

>     < Step: 0x62eece0>,
>     < Step: 0xc490660>,
>     < Step: 0xcb597d0>,
>     < Step: 0x65a4f60>,
>     < Step: 0xc43f4b0>,
>     < Step: 0xc43f3e0>,
>     < Step: 0x65c8f60>,
>     < Step: 0xc499230>,
>     (null) )} //null appeared?!

HINT!!

Check out the Step dealloc method (xD):

-(void)dealloc{
    if (![[PoolStep sharedPool] purgeFlag]) {
        [[PoolStep sharedPool] doneWithItem:self]; //put it in the object pool for reuse..
    } else {
        NSLog(@"=== STEP ====> [ %d ]", --_counter);
        [children release];
        [super dealloc];
    }
}

Another HINT!!

PoolStep is a singleton without @synchronize block in the sharedPool method, since it’s accessed by one thread only. (and the performance is needed)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:15:01+00:00Added an answer on May 23, 2026 at 3:15 pm

    Have you tried wrapping it and any other code that uses theSet in a synchronized(theSet) block, a threading issue could explain your issue. Maybe the null is caused by some intermediate state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
I am trying to create a set of objects using NSMutableSet. The object is
There are 2 choices (possibly more). Using NSSet as an example: NSMutableSet * mutableSet
The reason I'm asking this is because right now I use an NSMutableSet of
Using report builder 3.0, I have a report that queries a cube. How do
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
using file_get_contents , I open an Internet URL and get the contents of this
Using CRM 4, I have an entity form that contains a tab with an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.