Closed Bug 1505029 Opened 2 years ago Closed 1 year ago

Calling MOZ_CAN_RUN_SCRIPT with nsCOMPtr<nsISupports> causes build error

Categories

(Firefox Build System :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox67 fixed)

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: masayuki, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I hit these errors:
[task 2018-11-06T10:38:22.991Z] 10:38:22     INFO -  /builds/worker/workspace/build/src/editor/libeditor/HTMLEditorDataTransfer.cpp:1308:34: error: arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument)
[task 2018-11-06T10:38:22.991Z] 10:38:22     INFO -          InsertObject(bestFlavor, genericDataObj, isSafe,
[task 2018-11-06T10:38:22.991Z] 10:38:22     INFO -          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
[task 2018-11-06T10:38:22.991Z] 10:38:22     INFO -  /builds/worker/workspace/build/src/editor/libeditor/HTMLEditorDataTransfer.cpp:1451:55: error: arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument)
[task 2018-11-06T10:38:22.992Z] 10:38:22     INFO -              InsertObject(NS_ConvertUTF16toUTF8(type), object, isSafe,
[task 2018-11-06T10:38:22.992Z] 10:38:22     INFO -              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
[task 2018-11-06T10:38:22.992Z] 10:38:22     INFO -  2 errors generated.
https://treeherder.mozilla.org/logviewer.html#?job_id=210012990&repo=try&lineNumber=26761

InsertObject() is marked as MOZ_CAN_RUN_SCRIPT newly.

The second error is caused by this code:

  nsCOMPtr<nsISupports> object;
  variant->GetAsISupports(getter_AddRefs(object));
  nsresult rv =
    InsertObject(NS_ConvertUTF16toUTF8(type), object, isSafe,
                 aSourceDoc, aDroppedAt, aDoDeleteSelection);

but changing to as following, the error disappears:

  nsCOMPtr<nsISupports> object;
  variant->GetAsISupports(getter_AddRefs(object));
  nsCOMPtr<BlobImpl> blob = do_QueryInterface(object);
  nsresult rv =
    InsertObject(NS_ConvertUTF16toUTF8(type), blob, isSafe,
                 aSourceDoc, aDroppedAt, aDoDeleteSelection);

https://treeherder.mozilla.org/logviewer.html#?job_id=210069760&repo=try&lineNumber=27645

So, nsCOMPtr<nsISupports> must be accidentally considered as non-strong ref.
FYI: The 2nd argument of InsertObject() is nsISupports*.
Blocks: 1534370
Attachment #9050073 - Attachment description: Bug 1505029. Teach our static analysis about nsCOMPTr<nsISupports> being a strong ref. r=andi → Bug 1505029. Teach our static analysis about nsCOMPtr<nsISupports> being a strong ref. r=andi
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/356a982f5ba4
Teach our static analysis about nsCOMPtr<nsISupports> being a strong ref.  r=mccr8
Assignee: nobody → bzbarsky
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.