WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
226544
Drop legacy ActiveDOMObject::setPendingActivity() / unsetPendingActivity()
https://bugs.webkit.org/show_bug.cgi?id=226544
Summary
Drop legacy ActiveDOMObject::setPendingActivity() / unsetPendingActivity()
Chris Dumez
Reported
2021-06-02 10:49:03 PDT
Drop legacy ActiveDOMObject::setPendingActivity() / unsetPendingActivity(). They are too leak-prone. The modern way to do this is to either override ActiveDOMObject::virtualHasPendingActivity() or use ActiveDOMObject::makePendingActivity().
Attachments
Patch
(13.61 KB, patch)
2021-06-02 10:51 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(13.97 KB, patch)
2021-06-02 13:22 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2021-06-02 10:51:37 PDT
Created
attachment 430375
[details]
Patch
Darin Adler
Comment 2
2021-06-02 12:39:07 PDT
Comment on
attachment 430375
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=430375&action=review
> Source/WebCore/Modules/applepay/ApplePaySession.cpp:791 > + auto protectedJSWrapper = makePendingActivity(*this);
This object is not itself a JS wrapper. It is an object that protects the wrapper. So naming it "protected JS wrapper" is not quite right.
> Source/WebCore/Modules/mediasource/MediaSource.h:182 > + unsigned m_associatedRegistryCount { 0 };
Do we have a no-overflow guarantee? 32-bits is a lot of bits, but is it guaranteed enough?
> Source/WebCore/page/EventSource.cpp:278 > + auto protectedJSWrapper = makePendingActivity(*this);
Same variable name thought.
Chris Dumez
Comment 3
2021-06-02 12:44:50 PDT
(In reply to Darin Adler from
comment #2
)
> Comment on
attachment 430375
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=430375&action=review
> > > Source/WebCore/Modules/applepay/ApplePaySession.cpp:791 > > + auto protectedJSWrapper = makePendingActivity(*this); > > This object is not itself a JS wrapper. It is an object that protects the > wrapper. So naming it "protected JS wrapper" is not quite right.
jsWrapperProtector?
> > > Source/WebCore/Modules/mediasource/MediaSource.h:182 > > + unsigned m_associatedRegistryCount { 0 }; > > Do we have a no-overflow guarantee? 32-bits is a lot of bits, but is it > guaranteed enough?
I would just like to point out that ActiveDOMObject uses: unsigned m_pendingActivityInstanceCount So I did not change the situation with this patch. I need to look deeper into the code so see if there is a no-overflow guarantee as I am not familiar with it.
> > > Source/WebCore/page/EventSource.cpp:278 > > + auto protectedJSWrapper = makePendingActivity(*this); > > Same variable name thought.
Chris Dumez
Comment 4
2021-06-02 13:06:24 PDT
(In reply to Chris Dumez from
comment #3
)
> (In reply to Darin Adler from
comment #2
) > > Comment on
attachment 430375
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=430375&action=review
> > > > > Source/WebCore/Modules/applepay/ApplePaySession.cpp:791 > > > + auto protectedJSWrapper = makePendingActivity(*this); > > > > This object is not itself a JS wrapper. It is an object that protects the > > wrapper. So naming it "protected JS wrapper" is not quite right. > > jsWrapperProtector? > > > > > > Source/WebCore/Modules/mediasource/MediaSource.h:182 > > > + unsigned m_associatedRegistryCount { 0 }; > > > > Do we have a no-overflow guarantee? 32-bits is a lot of bits, but is it > > guaranteed enough? > > I would just like to point out that ActiveDOMObject uses: > unsigned m_pendingActivityInstanceCount > > So I did not change the situation with this patch. I need to look deeper > into the code so see if there is a no-overflow guarantee as I am not > familiar with it.
Looking at the code, I think JS could potentially cause an overflow by running this in a loop for the same mediaSource object: `window.URL.createObjectURL(mediaSource)` Not a regression in my patch. Switching to uint64_t would just delay the inevitable. Not sure how we usually deal with such things.
Chris Dumez
Comment 5
2021-06-02 13:10:51 PDT
Comment on
attachment 430375
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=430375&action=review
>>> Source/WebCore/Modules/mediasource/MediaSource.h:182 >>> + unsigned m_associatedRegistryCount { 0 }; >> >> Do we have a no-overflow guarantee? 32-bits is a lot of bits, but is it guaranteed enough? > > I would just like to point out that ActiveDOMObject uses: > unsigned m_pendingActivityInstanceCount > > So I did not change the situation with this patch. I need to look deeper into the code so see if there is a no-overflow guarantee as I am not familiar with it.
This is not a valid use case though so the script would have to have a bug or have bad intentions. The side effect though is only that the wrapper might get collected early (or leak). If a wrapper is collected early, the one consequence I am aware of is the inability to dispatch events. Do we think we have to deal with overflows here?
Geoffrey Garen
Comment 6
2021-06-02 13:18:44 PDT
> Looking at the code, I think JS could potentially cause an overflow by > running this in a loop for the same mediaSource object: > `window.URL.createObjectURL(mediaSource)` > > Not a regression in my patch. Switching to uint64_t would just delay the > inevitable. Not sure how we usually deal with such things.
I believe we usually deal with this issue by using uint64_t. I think that's how all WK2 object identifiers work. I don't agree that uint64_t delays the inevitable; I believe it is a complete fix, at least for any consumer electronic device in the foreseeable future. [
https://www.reddit.com/r/ProgrammerTIL/comments/4tspsn/c_it_will_take_approximately_97_years_to_overflow/
] In some cases, Checked<unsigned> might also be appropriate -- if we are willing to crash when the number gets too big.
Chris Dumez
Comment 7
2021-06-02 13:22:44 PDT
Created
attachment 430395
[details]
Patch
EWS
Comment 8
2021-06-02 14:09:36 PDT
Committed
r278372
(
238399@main
): <
https://commits.webkit.org/238399@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 430395
[details]
.
Radar WebKit Bug Importer
Comment 9
2021-06-02 14:10:20 PDT
<
rdar://problem/78782275
>
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