Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Carbon, gcc 4.0.1, override new/delete




On Jan 18, 2006, at 10:08 AM, Paul Carnine wrote:

The problem:

As part of debug builds, we override new/delete operators to do leak
checking and all sorts of other good-debugging-love. It appears that with
gcc 4.0.1, overriding new/delete causes problems as system library
allocation calls appear to (periodically?) use our new/delete methods.


The problem becomes serious as it appears our overrides are not consistantly
called. So in our applications we'll get called for a new, but not the
correspondiing delete. Or we'll get called for a delete on a buffer we
never allocated.

I think this is expected behavior, but I agree that it's new in gcc4 (used to build the Intel version of Mac OS X). In Mac OS X 10.4, the dyld component will automatically coalesce externally-visible symbols from multiple libraries. gcc4 tends to make more symbols externally visible than did gcc3, and so the system-provided new/delete operators are probably being coalesced with your new/delete operators, and yours are overriding the system-provided operators. The solution for this problem is most likely to mark your new/delete operators to have limited visibility outside of their linkage unit. See <http://developer.apple.com/documentation/DeveloperTools/ Conceptual/CppRuntimeEnv/index.html> for more details on this topic.


-eric


_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Carbon, gcc 4.0.1, override new/delete (From: Paul Carnine <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.