• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Add same object/key to NSMapTable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add same object/key to NSMapTable


  • Subject: Add same object/key to NSMapTable
  • From: Nathan Vander Wilt <email@hidden>
  • Date: Wed, 17 Jun 2009 18:33:32 -0700

The following (simplified test case) code will crash with NSZombieEnabled:

NSMapTable* testTable = [NSMapTable mapTableWithStrongToStrongObjects];
NSString* o = [@"test_object" mutableCopy];
NSString* k = @"test_key";
[testTable setObject:o forKey:k];
[o release];
[testTable setObject:o forKey:k];	// crash

What seems to be happening is that -[NSMapTable setObject:forKey:] does a plain release on the key's "old" object before retaining the "new" object. This can result in the situation above, where the retain of the "new" object is performed on a zombie created by the release of the (identical) "old".

I could find no documentation to the effect that re-assigning an object is not allowed, so can I assume this is indeed unintentional? If so, I've got this test case in project form and would be happy to file a bug.

thanks,
-natevw
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Add same object/key to NSMapTable
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Safari-4-like Pulldown List
  • Next by Date: Re: Notification/callback of successful CGEventPost?
  • Previous by thread: Re: Enter Key Behavior in NSTableView
  • Next by thread: Re: Add same object/key to NSMapTable
  • Index(es):
    • Date
    • Thread