FSMoveObjectToTrashSync has mismatched new/delete calls in its bowels

Originator:dmaclach
Number:rdar://9738519 Date Originated:July 7, 2011
Status:Open Resolved:
Product:Mac OS X Product Version:10.6.8
Classification:Bug Reproducible:Always
 
Summary:

Steps to Reproduce:
Run the attached app under valgrind:
valgrind TrashTest <file_folder_to delete>

Expected Results:
No Errors reported from valgrind

Actual Results:

==30388== Memcheck, a memory error detector
==30388== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==30388== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==30388== Command: /Users/dmaclach/Desktop/TrashTest/build/Debug/TrashTest /Users/dmaclach/Desktop/V8\ Test
==30388== 
--30388-- /Users/dmaclach/Desktop/TrashTest/build/Debug/TrashTest:
--30388-- dSYM directory is missing; consider using --dsymutil=yes
==30388== Syscall param access_extended(entries) points to uninitialised byte(s)
==30388==    at 0x10014616E: accessx_np (in /usr/lib/libSystem.B.dylib)
==30388==    by 0x100376FA8: _FSGetExtendedUserAccess (in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore)
==30388==    by 0x101EA4A5B: TFSInfo::GetExtendedUserAccess(unsigned int, unsigned int, unsigned int&) const (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EA4977: TFSInfo::FetchExtendedUserAccess() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EA48AA: TFSInfo::Initialize(FSRef const&, FSRef const&, TUString const&, TFSCatalogInfo const&, unsigned int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EA453C: TFSInfo::Initialize(FSRef const&, unsigned int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EB7817: TFSInfo::Initialize(__CFURL const*) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08AE2: TFSCopyOperation::DoMoveToTrash(TCountedPtr<TCFURLInfo> const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EFE655: _NodeOperation (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x1003DEFCD: _FSOperateOnObjectSync (in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore)
==30388==    by 0x100000D86: main (in /Users/dmaclach/Desktop/TrashTest/build/Debug/TrashTest)
==30388==  Address 0x7fff5fbfd5c8 is on thread 1's stack
==30388== 
==30388== Mismatched free() / delete / delete []
==30388==    at 0x1000117D2: operator delete[](void*) (vg_replace_malloc.c:409)
==30388==    by 0x101ECF548: TPropertyStream::SetLength(int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC6B9: TPropertyStream::WriteData(unsigned char const*, int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC639: TPropertyStream::Write(unsigned int, unsigned char const*, unsigned int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EC022A: IAStoreStream::MaybeFlushBuffer() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECCB26: Page::Write(IAStorage*, IAStoreStream*) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC996: BTree::Flush() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE88C: TPropertyInfo::FlushChanges(TCountedPtr<TFSInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE579: TPropertyInfo::FlushChanges(TCountedPtr<TCFURLInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE3B1: THFSPlusPropertyStore::FlushChanges() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08468: TFSCopyOperation::MoveProperties(THFSPlusExtendedPropertyIterator&, TCountedPtr<TCFURLInfo>&, TUString const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08D05: TFSCopyOperation::DoMoveToTrash(TCountedPtr<TCFURLInfo> const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==  Address 0x101b124a0 is 0 bytes inside a block of size 4,096 alloc'd
==30388==    at 0x100011553: calloc (vg_replace_malloc.c:467)
==30388==    by 0x101ECE73D: TPropertyInfo::FlushChanges(TCountedPtr<TFSInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE579: TPropertyInfo::FlushChanges(TCountedPtr<TCFURLInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE3B1: THFSPlusPropertyStore::FlushChanges() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08468: TFSCopyOperation::MoveProperties(THFSPlusExtendedPropertyIterator&, TCountedPtr<TCFURLInfo>&, TUString const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08D05: TFSCopyOperation::DoMoveToTrash(TCountedPtr<TCFURLInfo> const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EFE655: _NodeOperation (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x1003DEFCD: _FSOperateOnObjectSync (in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore)
==30388==    by 0x100000D86: main (in /Users/dmaclach/Desktop/TrashTest/build/Debug/TrashTest)
==30388== 
==30388== Mismatched free() / delete / delete []
==30388==    at 0x1000117D2: operator delete[](void*) (vg_replace_malloc.c:409)
==30388==    by 0x101EC2833: TPropertyStream::~TPropertyStream() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EC27E7: IAStorage::~IAStorage() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EC26A0: BuddyStorage::~BuddyStorage() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE95C: TPropertyInfo::FlushChanges(TCountedPtr<TFSInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE579: TPropertyInfo::FlushChanges(TCountedPtr<TCFURLInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE3B1: THFSPlusPropertyStore::FlushChanges() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08468: TFSCopyOperation::MoveProperties(THFSPlusExtendedPropertyIterator&, TCountedPtr<TCFURLInfo>&, TUString const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08D05: TFSCopyOperation::DoMoveToTrash(TCountedPtr<TCFURLInfo> const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EFE655: _NodeOperation (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x1003DEFCD: _FSOperateOnObjectSync (in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore)
==30388==    by 0x100000D86: main (in /Users/dmaclach/Desktop/TrashTest/build/Debug/TrashTest)
==30388==  Address 0x101b3cc20 is 0 bytes inside a block of size 24,576 alloc'd
==30388==    at 0x100011553: calloc (vg_replace_malloc.c:467)
==30388==    by 0x101ECF522: TPropertyStream::SetLength(int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC6B9: TPropertyStream::WriteData(unsigned char const*, int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC639: TPropertyStream::Write(unsigned int, unsigned char const*, unsigned int) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101EC022A: IAStoreStream::MaybeFlushBuffer() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECCB26: Page::Write(IAStorage*, IAStoreStream*) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECC996: BTree::Flush() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE88C: TPropertyInfo::FlushChanges(TCountedPtr<TFSInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE579: TPropertyInfo::FlushChanges(TCountedPtr<TCFURLInfo> const&, TCountedPtr<TPropertyInfoList> const&, bool) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101ECE3B1: THFSPlusPropertyStore::FlushChanges() (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08468: TFSCopyOperation::MoveProperties(THFSPlusExtendedPropertyIterator&, TCountedPtr<TCFURLInfo>&, TUString const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388==    by 0x101F08D05: TFSCopyOperation::DoMoveToTrash(TCountedPtr<TCFURLInfo> const&) (in /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv)
==30388== 
==30388== 
==30388== HEAP SUMMARY:
==30388==     in use at exit: 532,809 bytes in 2,778 blocks
==30388==   total heap usage: 6,822 allocs, 4,044 frees, 1,153,372 bytes allocated
==30388== 
==30388== LEAK SUMMARY:
==30388==    definitely lost: 0 bytes in 0 blocks
==30388==    indirectly lost: 0 bytes in 0 blocks
==30388==      possibly lost: 0 bytes in 0 blocks
==30388==    still reachable: 532,809 bytes in 2,778 blocks
==30388==         suppressed: 0 bytes in 0 blocks
==30388== Rerun with --leak-check=full to see details of leaked memory
==30388== 
==30388== For counts of detected and suppressed errors, rerun with: -v
==30388== Use --track-origins=yes to see where uninitialised values come from
==30388== ERROR SUMMARY: 15 errors from 3 contexts (suppressed: 0 from 0)

Regression:

Notes:
On Chrome we also see
MismatchedFree
Mismatched free() / delete / delete []
  operator delete(void*) (mp/valgrind-src/valgrind-memcheck/valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:387)
  THFSPlusCatalog::~THFSPlusCatalog()
  TNode::SetCatalog(THFSPlusCatalog*)
  TMountPointList::AddVolume(short, bool)
  TMountPointList::Find(short, TNode::StPopulating*)
  TMountPointList::SupportsInvisibleBit(short, TNode::StPopulating*, bool)
  THFSPlusPropertyStore::Open(bool, bool) const
  THFSPlusPropertyStore::GetProperties(bool) const
  TFSCopyOperation::GetSourcePropertyStore(THFSPlusRef const&)
  TFSCopyOperation::DoMoveToTrash(THFSPlusRef const&)
  TFSCopyOperation::Run()
  _FSOperation
  _FSOperateOnObjectSync
  FSMoveObjectToTrashSync
 ...
Address 0x13541630 is 0 bytes inside a block of size 14 alloc'd
  operator new[](unsigned long) (mp/valgrind-src/valgrind-memcheck/valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:305)
  NewHFSUniStr255(__CFString const*)
  THFSPlusCatalog::SystemBuildVersion()
  THFSPlusCatalog::THFSPlusCatalog(TNode*, short, FSVolumeInfo const&)
  TMountPointList::AddVolume(short, bool)
  TMountPointList::Find(short, TNode::StPopulating*)
  TMountPointList::SupportsInvisibleBit(short, TNode::StPopulating*, bool)
  THFSPlusPropertyStore::Open(bool, bool) const
  THFSPlusPropertyStore::GetProperties(bool) const
  TFSCopyOperation::GetSourcePropertyStore(THFSPlusRef const&)
  TFSCopyOperation::DoMoveToTrash(THFSPlusRef const&)
  TFSCopyOperation::Run()
  _FSOperation
  _FSOperateOnObjectSync
  FSMoveObjectToTrashSync
...

Comments

Source code for sample

I can't attach the project and app, but here's the source for the sample

#include <CoreFoundation/CoreFoundation.h>

#include <string>

#include <CoreServices/CoreServices.h>

bool FSRefFromPath(const std::string& path, FSRef* ref) {

OSStatus status = FSPathMakeRef((const UInt8*)path.c_str(), ref, nil);

return status == noErr;

}

int main (int argc, const char * argv[]) {

FSRef path_ref;

if (!FSRefFromPath(argv[1], &path_ref)) {

printf("Failed with %s\n", argv[1]);

return 1;

}

FSRef new_path_ref;

OSStatus status = FSMoveObjectToTrashSync(&path_ref, &new_path_ref, kFSFileOperationDefaultOptions);

if (status != noErr) {

printf("Failed with %d\n", status);

return 1;

}

return 0;

}

By dmaclach at July 7, 2011, 8 p.m. (reply...)

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!