Bug 59656 - Fix OwnPtr issues in IndexedDB
Summary: Fix OwnPtr issues in IndexedDB
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-27 16:40 PDT by Adam Barth
Modified: 2011-04-28 11:26 PDT (History)
7 users (show)

See Also:


Attachments
Patch (15.09 KB, patch)
2011-04-27 16:42 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Patch (1.39 KB, patch)
2011-04-27 23:49 PDT, Adam Barth
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2011-04-27 16:40:49 PDT
Fix OwnPtr issues in IndexedDB
Comment 1 Adam Barth 2011-04-27 16:42:20 PDT
Created attachment 91378 [details]
Patch
Comment 2 David Levin 2011-04-27 16:46:13 PDT
Comment on attachment 91378 [details]
Patch

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

> Source/WebCore/platform/leveldb/LevelDBDatabase.cpp:102
> +    OwnPtr<LevelDBDatabase> result = adoptPtr(new LevelDBDatabase());

Not required (cq+ is ok with me) but might want to remove the ().
Comment 3 Eric Seidel (no email) 2011-04-27 16:47:16 PDT
Comment on attachment 91378 [details]
Patch

Yay!  I'm kinda surprised it got landed as it was.
Comment 4 Eric Seidel (no email) 2011-04-27 16:52:05 PDT
In fareness to Steve, I think Darin's document is due for a refresh: http://www.webkit.org/coding/RefPtr.html.  Some of what seemed "obviously" wrong in the previous commit, it not actually that obvious of patterns of WebCore.  But we do need to be careful to get our memory management (and header includes) correct.
Comment 5 Adam Barth 2011-04-27 16:52:14 PDT
Committed r85122: <http://trac.webkit.org/changeset/85122>
Comment 6 WebKit Review Bot 2011-04-27 17:30:49 PDT
http://trac.webkit.org/changeset/85122 might have broken SnowLeopard Intel Release (Tests)
Comment 7 David Grogan 2011-04-27 20:05:47 PDT
This busticated the clang build:

http://build.chromium.org/p/chromium.webkit/builders/Mac%20Clang%20Builder%20%28dbg%29/builds/6490/steps/compile/logs/stdio

In file included from /b/build/slave/Mac_Clang_Builder__dbg_/build/src/third_party/WebKit/Source/WebCore/WebCore.gyp/../platform/leveldb/LevelDBDatabase.cpp:27:
In file included from ../platform/leveldb/LevelDBDatabase.h:31:
../../JavaScriptCore/wtf/OwnPtr.h:57:9: error: function 'WTF::OwnPtr<WebCore::<anonymous>::ComparatorAdapter>::OwnPtr' has internal linkage but is not defined [-Werror]
        OwnPtr(const OwnPtr<ValueType>&);
        ^
/b/build/slave/Mac_Clang_Builder__dbg_/build/src/third_party/WebKit/Source/WebCore/WebCore.gyp/../platform/leveldb/LevelDBDatabase.cpp:100:31: note: used here
    OwnPtr<ComparatorAdapter> comparatorAdapter = adoptPtr(new ComparatorAdapter(comparator));
                              ^
1 error generated.
Comment 8 Adam Barth 2011-04-27 22:58:20 PDT
> This busticated the clang build:

I have no idea what that error means.  That line of code is one of the most common patterns in WebKit.  Maybe it's a compiler bug?
Comment 9 Adam Barth 2011-04-27 23:47:59 PDT
Maciej has a theory for how to fix this error.
Comment 10 Adam Barth 2011-04-27 23:49:56 PDT
Created attachment 91436 [details]
Patch
Comment 11 Maciej Stachowiak 2011-04-27 23:51:36 PDT
Comment on attachment 91436 [details]
Patch

r=me
Comment 12 Adam Barth 2011-04-27 23:53:30 PDT
> r=me

Thanks!
Comment 13 Adam Barth 2011-04-27 23:56:42 PDT
Committed r85169: <http://trac.webkit.org/changeset/85169>
Comment 14 Steve Block 2011-04-28 02:59:50 PDT
Thanks for fixing this and apologies for missing the include problems in the original patch.

I wasn't aware that we should always use (Pass)OwnPtr every time ownership of an object is being transferred. What exactly is the policy? It would be great if the document could be updated for future reference.
Comment 15 Adam Barth 2011-04-28 11:26:29 PDT
> I wasn't aware that we should always use (Pass)OwnPtr every time ownership of an object is being transferred. What exactly is the policy? It would be great if the document could be updated for future reference.

The policy is that we should try to avoid ever having a "naked new," which means every call to new should be immediately followed by either adoptRef (for ref-counted objects) or adoptPtr (for objects with a single owner).  Everything else follows from the C++ type system.

Turning on strict mode tightens the type system to better enforce this style.  Once we've got that all working, we'll probably add a check-webkit-style nag about "naked new" so that these problems can be flagged automagically.  (There's already an ASSERT that enforces this behavior for ref-counted objects.)