IORegistryEntry::copyProperty() does not actually copy the property

Originator:phil
Number:rdar://12082665 Date Originated:12-Aug-2012 02:16 PM
Status:Open Resolved:
Product:Mac OS X Product Version:10.7
Classification:Other Bug Reproducible:Always
 
Summary:
The kernel's IORegistryEntry class has a set of methods called copyProperty(). The source code for these reveals that the property value is in fact NOT copied.

Steps to Reproduce:
- Obtain a dictionary or array property value from a registry entry using copyProperty()
- attempt to modify the property value

Expected Results:
- modifying the copied collection should work

Actual Results:
- kernel panic: "Trying to change a collection in the registry"

Notes:
I suspect this is an optimisation for legacy code that uses copyProperty and does not in fact require a copy. However, this makes it essentially superfluous as IORegistryEntry::getProperty() is almost identical - IORegistryEntry::copyProperty() in fact calls getProperty() and retain()s the result.
Worse, the name suggests copying, and the documentation for this method is vague and does not explicitly state that no copy is performed.

Suggested fix:
- Mark copyProperty() as deprecated
- Update the documentation for copyProperty() to be clear about the non-copying behaviour.
- Update getProperty() method documentation to say that returned values are immutable and should be copied before modification.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!