URL: <http://savannah.gnu.org/bugs/?35477>
Summary: -[NSValue description] dereferences nonretained pointers Project: GNUstep Submitted by: waha_06x36 Submitted on: Wed 08 Feb 2012 02:42:42 PM GMT Category: Base/Foundation Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Details: 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. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Wed 08 Feb 2012 02:42:42 PM GMT Name: test.m Size: 617B By: waha_06x36 <http://savannah.gnu.org/bugs/download.php?file_id=25021> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?35477> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-gnustep mailing list Bug-gnustep@gnu.org https://lists.gnu.org/mailman/listinfo/bug-gnustep