Calling MOZ_CAN_RUN_SCRIPT with nsCOMPtr<nsISupports> causes build error

RESOLVED FIXED in Firefox 67

Status

defect
RESOLVED FIXED
9 months ago
4 months ago

People

(Reporter: masayuki, Assigned: bzbarsky)

Tracking

(Blocks 1 bug)

Trunk
mozilla67
Dependency tree / graph

Firefox Tracking Flags

(firefox67 fixed)

Details

Attachments

(1 attachment)

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: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.