WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
Bug 59470
Prohibit the use of OwnPtr<T*>
https://bugs.webkit.org/show_bug.cgi?id=59470
Summary
Prohibit the use of OwnPtr<T*>
Adrienne Walker
Reported
2011-04-26 11:03:38 PDT
Prohibit the use of OwnPtr<T*>
Attachments
Patch
(2.64 KB, patch)
2011-04-26 11:04 PDT
,
Adrienne Walker
no flags
Details
Formatted Diff
Diff
Patch
(2.56 KB, patch)
2011-04-26 12:13 PDT
,
Adrienne Walker
no flags
Details
Formatted Diff
Diff
Patch
(2.56 KB, patch)
2011-04-26 16:23 PDT
,
Adrienne Walker
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Adrienne Walker
Comment 1
2011-04-26 11:04:47 PDT
Created
attachment 91129
[details]
Patch
Adrienne Walker
Comment 2
2011-04-26 11:09:51 PDT
There may be some better way to implement this, but I think it would be an excellent idea to prevent somebody accidentally using OwnPtr<T*> when they intended OwnPtr<T>. I can't think of any usage for the former. (Also, I'm a little unsure of who to CC on this bug, so please add others.)
WebKit Review Bot
Comment 3
2011-04-26 11:26:49 PDT
Attachment 91129
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8509701
Build Bot
Comment 4
2011-04-26 12:07:53 PDT
Attachment 91129
[details]
did not build on win: Build output:
http://queues.webkit.org/results/8508728
WebKit Review Bot
Comment 5
2011-04-26 12:11:43 PDT
Attachment 91129
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/8505948
Adrienne Walker
Comment 6
2011-04-26 12:13:51 PDT
Created
attachment 91144
[details]
Patch
Adrienne Walker
Comment 7
2011-04-26 12:14:30 PDT
Let's try this again now that the blocking bugfix has landed.
WebKit Review Bot
Comment 8
2011-04-26 12:57:47 PDT
Attachment 91144
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8509721
Adrienne Walker
Comment 9
2011-04-26 13:23:57 PDT
Comment on
attachment 91144
[details]
Patch Oops. Need to touch up DRT as well.
WebKit Review Bot
Comment 10
2011-04-26 13:54:35 PDT
Attachment 91129
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8510701
Build Bot
Comment 11
2011-04-26 14:01:35 PDT
Attachment 91144
[details]
did not build on win: Build output:
http://queues.webkit.org/results/8509734
WebKit Review Bot
Comment 12
2011-04-26 15:34:52 PDT
Attachment 91144
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/8508780
Adrienne Walker
Comment 13
2011-04-26 16:23:33 PDT
Created
attachment 91177
[details]
Patch
Adrienne Walker
Comment 14
2011-04-26 16:23:59 PDT
Third time's a charm for fixing all the build errors.
Geoffrey Garen
Comment 15
2011-04-26 16:59:51 PDT
Comment on
attachment 91177
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=91177&action=review
r=me
> Source/JavaScriptCore/wtf/OwnPtr.h:179 > + template<typename T> class OwnPtr<T*> { > + // Prevent usage as a real OwnPtr by not defining any functions. > + }; > +#endif
I believe you can do even better here by just using a declaration with no definition.
Adrienne Walker
Comment 16
2011-04-26 17:03:50 PDT
(In reply to
comment #15
)
> (From update of
attachment 91177
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=91177&action=review
> > r=me
Thanks for all the reviews today. :)
> > Source/JavaScriptCore/wtf/OwnPtr.h:179 > > + template<typename T> class OwnPtr<T*> { > > + // Prevent usage as a real OwnPtr by not defining any functions. > > + }; > > +#endif > > I believe you can do even better here by just using a declaration with no definition.
That would be cleaner. I'll do that before landing.
Build Bot
Comment 17
2011-04-26 17:05:00 PDT
Attachment 91177
[details]
did not build on win: Build output:
http://queues.webkit.org/results/8507775
Adrienne Walker
Comment 18
2011-04-26 17:25:08 PDT
(In reply to
comment #16
)
> (In reply to
comment #15
)
> > > Source/JavaScriptCore/wtf/OwnPtr.h:179 > > > + template<typename T> class OwnPtr<T*> { > > > + // Prevent usage as a real OwnPtr by not defining any functions. > > > + }; > > > +#endif > > > > I believe you can do even better here by just using a declaration with no definition. > > That would be cleaner. I'll do that before landing.
After some study, I think an empty class rather than an incomplete declaration is better. If the class is incomplete, then it's harder to #ifdef out this error because every class that is-a or has-a class with an OwnPtr<T*> needs the ALLOW_RAW_POINTER_IN_OWNPTR define. Hopefully that should go away soon, but in the short term MediaPlayer.h is used in a number of places. Also, the error message points to OwnPtr.h in the former case where somebody might see the comment, but just says the slightly more obscure "incomplete declaration" in the latter.
WebKit Review Bot
Comment 19
2011-04-26 18:22:01 PDT
Attachment 91144
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8510781
Adrienne Walker
Comment 20
2011-04-27 11:11:10 PDT
Oh, yuck. It looks like the Windows port is set up to handle OwnPtr<HBITMAP> (which is a void*), but has a deleteOwnPtr(HBITMAP) function which will properly clean up its resources. So, I can't disallow all OwnPtr<T*>, just all except any except the 10 or so port-specific pointer types listed in OwnPtrCommon.h. I'll have to take another look at this patch to account for that while still disallowing the general case.
Darin Adler
Comment 21
2011-06-18 12:46:21 PDT
Comment on
attachment 91177
[details]
Patch Clearing review flag because we need to rework this for Windows’ sake. Best possibility would probably be to change Windows to use to something other than OwnPtr. It’s not safe to have it using OwnPtr with void*!
Adrienne Walker
Comment 22
2011-06-20 09:41:40 PDT
(In reply to
comment #21
)
> (From update of
attachment 91177
[details]
) > Clearing review flag because we need to rework this for Windows’ sake. Best possibility would probably be to change Windows to use to something other than OwnPtr. It’s not safe to have it using OwnPtr with void*!
Ack. I thought I had closed this bug. It turns out that I was just mistaken. All the Windows-specific versions of OwnPtr like OwnPtr<HBITMAP> have their own specialized delete function which gets called. And thanks to template magic, for the general case of T, it turns out that OwnPtr<T*> is identical to OwnPtr<T> in terms of what gets stored in the OwnPtr and which delete function gets called.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug