bugGNUstep - Bugs: bug #18804, -[NSURLHandle resourceData] fails...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #18804: -[NSURLHandle resourceData] fails to retain & autorelease its returned value

Submitted by:  Larry Campbell <lcampbel>
Submitted on:  Tue 16 Jan 2007 06:29:15 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: Change RequestStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Thu 18 Jan 2007 08:49:44 PM UTC, comment #3:

I would like to note that this class/method seems a likely candidate to be used in certain performance critical servers in potentially multithreaded environments. The copy/autorelease approach could have a significant impact in the multithreaded case due to accessing the autorelease pool. I would favor avoiding returning an autoreleased objects in this case.

David Ayers <ayers>
Project Member
Wed 17 Jan 2007 01:44:26 PM UTC, comment #2:

I stand corrected. I checked and found that MacOS X behaves the same way. I withdraw my suggestion.

Larry Campbell <lcampbel>
Wed 17 Jan 2007 08:37:56 AM UTC, comment #1:

This is plainly not a bug (since it's legitimate/normal to return ivars whose life is that of the receiver, and the GNUstep and MacOS-X documentation don't say that the value will be autoreleased), so I have treated it as a change request instead.
I've implemented it for consistency.

This behavior is actually an undocumented implementation detail, and can't be guaranteed in GNUstep-base or Cocoa Foundation.
This means that if an application depends on this implementation detail then there is a bug in the application ... the general rule for handling objects returned by methods is that the caller MUST retain the object immediately before calling any other method which might possibly cause it to be destroyed. Assuming that the object will persist as long as the enclosing autorelease pool persists is an error unless the method is specifically documented as returning an autoreleased object.

Richard Frith-Macdonald <CaS>
Project Member
Tue 16 Jan 2007 06:29:15 PM UTC, original submission:

-[NSURLHandle resourceData] should always retain & autorelease its returned value; otherwise, releasing the handle will deallocate the data.

The fix: in NSURLHandle.m, at line 541 (wrt gnustep-base 1.13.0), change this:

if (d != nil)
{
ASSIGNCOPY(_data, d);
}
return _data;

to this:

if (d != nil)
{
ASSIGNCOPY(_data, d);
}
return AUTORELEASE([_data copy]);

Larry Campbell <lcampbel>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ayers (Posted a comment)
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by lcampbel (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Jan 2007 08:37:56 AM UTCCaSItem GroupBug=>Change Request
      StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 16 Jan 2007 06:29:15 PM UTClcampbelCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1