Move the IPCNotification instead of copying it in the DWPNotificationCallbacks constructor
Categories
(Core :: DOM: Push Subscriptions, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr153 | --- | unaffected |
| firefox160 | --- | wontfix |
| firefox161 | --- | wontfix |
| firefox162 | --- | fixed |
People
(Reporter: Sylvestre, Assigned: ltenenbaum, Mentored)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: good-first-bug, regression, Whiteboard: [lang=c++])
Attachments
(1 external file)
Filing as a good first bug to learn workflows.
Coverity (CID 1701240, COPY_INSTEAD_OF_MOVE) flags the DWPNotificationCallbacks constructor in dom/push/Declarative.cpp. It takes its IPCNotification argument by value and then copies it into the base class:
DWPNotificationCallbacks(const nsAString& aScope, nsIPrincipal* aPrincipal,
IPCNotification aNotification)
: NotificationCallbacksCommon(aScope, aPrincipal, aNotification) {}
NotificationCallbacksCommon also takes IPCNotification by value and moves it into its member, so the copy here is wasted (IPCNotification holds strings and arrays). The fix is to move the parameter, which is not used afterwards:
: NotificationCallbacksCommon(aScope, aPrincipal,
std::move(aNotification)) {}
Link to the code:
https://searchfox.org/firefox-main/source/dom/push/Declarative.cpp
To verify the fix:
./mach build
./mach test dom/push/test/
./mach format dom/push/Declarative.cpp
Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html
Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.
Comment 1•5 days ago
|
||
Set release status flags based on info from the regressing bug 2068765
:ltenenbaum, since you are the author of the regressor, bug 2068765, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
| Reporter | ||
Updated•5 days ago
|
Comment 2•5 days ago
•
|
||
Well the only caller passes it as an rvalue where I expect copy elision, so I don't think a copy is actually happening.
RefPtr<DWPNotificationCallbacks> dwpCallbacks = new DWPNotificationCallbacks(
aScope, &aPrincipal, IPCNotification(id, aOptions));
But then I hate C++, these things are too implicit and easy to fire footgun. Rust for DOM when? 🥺
| Assignee | ||
Comment 3•5 days ago
|
||
I think it does get copied in the DWPNotificationCallbacks constructor…
| Assignee | ||
Updated•5 days ago
|
| Assignee | ||
Comment 4•5 days ago
|
||
Updated•5 days ago
|
Comment 6•3 days ago
|
||
| bugherder | ||
Description
•