Re: ARC: __weak variable holds x instead of y
Re: ARC: __weak variable holds x instead of y
- Subject: Re: ARC: __weak variable holds x instead of y
- From: Mikkel Islay <email@hidden>
- Date: Sat, 08 Sep 2012 10:27:11 +0200
On 7 Sep 2012, at 16:25, Steve Christensen wrote:
> objc[46805]: __weak variable @ 0x909c530 holds 0x70000000 instead of 0x7c146b0
>
> It appears that something's changing unexpectedly, but I don't have a good idea how to track down where it's happening so I can fix it. Any debugging help on this one?
You can set a watch on your __weak ref and the object it is meant to reference, and see if their lifetimes behave unexpectedly.
The warning is emitted by this method in objc-weak.mm
void
arr_clear_deallocating(weak_table_t *weak_table, id referent) {
{
weak_entry_t *entry = weak_entry_for_referent(weak_table, referent);
if (entry == NULL) {
/// XXX shouldn't happen, but does with mismatched CF/objc
//printf("XXX no entry for clear deallocating %p\n", referent);
return;
}
// zero out references
for (size_t i = 0; i < entry->referrers.num_allocated; ++i) {
id *referrer = entry->referrers.refs[i].referrer;
if (referrer) {
if (*referrer == referent) {
*referrer = nil;
}
else if (*referrer) {
_objc_inform("__weak variable @ %p holds %p instead of %p\n", referrer, *referrer, referent);
}
}
}
weak_entry_remove_no_lock(weak_table, entry);
weak_table->num_weak_refs--;
}
}
Mikkel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden