Bug 119810 - [Mac] No AutoreleasePool leaks when dragging image out of WebView
Summary: [Mac] No AutoreleasePool leaks when dragging image out of WebView
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-08-14 11:56 PDT by Joseph Pecoraro
Modified: 2013-08-14 17:44 PDT (History)
2 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (1.32 KB, patch)
2013-08-14 12:08 PDT, Joseph Pecoraro
joepeck: review-
Details | Formatted Diff | Diff
[PATCH] Proposed fix - convert pthread to dispatch block (2.90 KB, patch)
2013-08-14 16:21 PDT, Joseph Pecoraro
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2013-08-14 11:56:59 PDT
objc[41140]: Object 0x7fc0b70fa430 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

(lldb) bt
* thread #39: tid = 0x1dc29a, 0x00007fff927f2a0d libobjc.A.dylib`objc_autoreleaseNoPool, stop reason = breakpoint 1.1
    frame #0: 0x00007fff927f2a0d libobjc.A.dylib`objc_autoreleaseNoPool
    frame #1: 0x00007fff927de402 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::autoreleaseSlow(objc_object*) + 108
    frame #2: 0x00007fff927f2bec libobjc.A.dylib`_objc_rootAutorelease2(objc_object*) + 75
    frame #3: 0x0000000110626021 WebCore`WTF::StringImpl::operator NSString*() [inlined] WTF::RetainPtr<__CFString const*>::leakRef(this=0x0000000000000000, this=0x0000000000000000, this=0x0000000000000000) + 44 at FoundationExtras.h:38
    frame #4: 0x0000000110625ff5 WebCore`WTF::StringImpl::operator NSString*(this=<unavailable>) + 21 at StringImplMac.mm:31
    frame #5: 0x000000010fdff335 WebCore`setMetaData [inlined] WTF::String::operator NSString*() const + 23 at WTFString.h:424
    frame #6: 0x000000010fdff31e WebCore`setMetaData(context=0x00000001150e5a68) + 30 at FileSystemMac.mm:80
    frame #7: 0x00007fff8e30b7a2 libsystem_c.dylib`_pthread_start + 327
    frame #8: 0x00007fff8e2f81e1 libsystem_c.dylib`thread_start + 13
Comment 1 Radar WebKit Bug Importer 2013-08-14 11:57:25 PDT
<rdar://problem/14738085>
Comment 2 Joseph Pecoraro 2013-08-14 12:08:32 PDT
Created attachment 208751 [details]
[PATCH] Proposed Fix
Comment 3 Joseph Pecoraro 2013-08-14 12:09:06 PDT
* STEPS TO REPRODUCE
1. Open <http://bogojoker.com> in Safari
2. Drag an image to your desktop
  => leaks
Comment 4 Joseph Pecoraro 2013-08-14 12:12:09 PDT
* LEAK (allocation backtrace)
Leak: 0x7f8617e96820  size=64  zone: DefaultMallocZone_0x106134000   __NSCFString  ObjC  CoreFoundation  "/Users/pecoraro/Desktop/bogojoker.png"
	Call stack: [thread 0x10bad7000]:
        | thread_start
        | _pthread_start
        | WebCore::setMetaData(void*)
        | WTF::StringImpl::operator NSString*()
        | WTF::StringImpl::createCFString()
        | CFStringCreateWithBytes
        | __CFStringCreateImmutableFunnel3
        | _CFRuntimeCreateInstance
        | malloc_zone_malloc
Comment 5 Joseph Pecoraro 2013-08-14 12:25:59 PDT
Comment on attachment 208751 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=208751&action=review

> Source/WebCore/platform/mac/FileSystemMac.mm:77
>  static void* setMetaData(void* context)

Mitz has a good suggestion. Instead of spawning a pthread for setMetaData (old code) we can just dispatch a block to do this. I'll look into that.
Comment 6 Joseph Pecoraro 2013-08-14 16:21:03 PDT
Created attachment 208768 [details]
[PATCH] Proposed fix - convert pthread to dispatch block

Verified this by dragging and dropping images out of Safari to the Desktop and checking the "Get Info" finder window for "Where from" information.
Comment 7 mitz 2013-08-14 16:26:49 PDT
Comment on attachment 208768 [details]
[PATCH] Proposed fix - convert pthread to dispatch block

View in context: https://bugs.webkit.org/attachment.cgi?id=208768&action=review

> Source/WebCore/platform/mac/FileSystemMac.mm:81
> +        wkSetMetadataURL(URLStringCopy, referrerCopy, (NSString *)String::fromUTF8(fileSystemRepresentation(pathCopy).data()));

You should just use -[NSString fileSystemRepresentation].
Comment 8 Joseph Pecoraro 2013-08-14 17:44:14 PDT
Committed <http://trac.webkit.org/changeset/154086>.