bugGNUstep - Bugs: bug #35477, -[NSValue description]...

 
 

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

bug #35477: -[NSValue description] dereferences nonretained pointers

Submitted by:  Dag Ågren <waha_06x36>
Submitted on:  Wed 08 Feb 2012 02:42:42 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 08 Feb 2012 03:35:39 PM UTC, comment #1:

Thanks very much. I make the suggested change in svn.

Richard Frith-Macdonald <CaS>
Project Member
Wed 08 Feb 2012 02:42:42 PM UTC, original submission:

Calling description on an NSValue created with valueWithNonretainedPointer: causes the pointer to be dereferenced, and its desription method to be called. This is not safe, and causes crashes under several different conditions.

First, the object may have been released. This would make it unsafe to grab the actual pointer and use it, but calling description should still be safe.

Second, NSValues are often used for breaking retain cycles in complex data structures. Calling description on the referenced object in this case can cause an endless loop which blows the stack.

Included is a test program with two statements that crash. Neither should crash under these circumstances.

The fix is straightforward: Remove the call to description on the contained object, and merely print the numerical value of the contained pointer. This matches the behaviour of Cocoa on OS X.

Dag Ågren <waha_06x36>

 

Attached Files
file #25021:  test.m added by waha_06x36 (617B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by waha_06x36 (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 08 Feb 2012 03:35:39 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Wed 08 Feb 2012 02:42:42 PM UTCwaha_06x36Attached File-=>Added test.m, #25021

    Back to the top


    Powered by Savane 3.1-cleanup1