Closed Bug 1233060 Opened 9 years ago Closed 7 years ago

No unprotected references in Bluetooth backend code

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: tzimmermann, Assigned: tzimmermann)

References

Details

Attachments

(1 file)

We have unprotected references to result handlers in the Bluetooth backend code. This leads to ref-counting problems like bug 1232670. The correct fix is to always keep classes protected by smart pointers.
Nathan,

I want to construct objects with |MakeAndAddRef| and pass the raw pointer to a function. But the |already_AddRefed| that is returned by |MakeAndAddRef| cannot be converted to a raw pointer.

So I added a new helper named |MakeRef| that returns a |RefPtr|. I'd rather prefer to change the return type of |MakeAndAddRef| to |RefPtr| and fix the rest of tree where necessary.

I'd like to ask for your opinion on this. Are there better options?
Attachment #8698994 - Flags: feedback?(nfroyd)
Comment on attachment 8698994 [details] [diff] [review]
01_convert_bluedroid_service.patch

Review of attachment 8698994 [details] [diff] [review]:
-----------------------------------------------------------------

I don't think this patch is going in the right direction because we have things like:

http://mxr.mozilla.org/mozilla-central/source/mfbt/RefPtr.h#259

which will make all of the examples herein compile-time errors with new-enough compilers (if they're not already; I don't know what GCC version we're using across our B2G compilers).

I don't think converting MakeAndAddRef to MakeRef is a good idea because then things like:

NS_DispatchToCurrentThread(MakeAndAddRef<T>(...));

and associated event dispatching variants won't work correctly.  And:

NS_DispatchToCurrentThread(MakeRef<T>(...).forget());

is unwieldy.

You could make NS_DispatchToCurrentThread take RefPtr, but that doesn't communicate the transfer of ownership that the current signature does.
Attachment #8698994 - Flags: feedback?(nfroyd)
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: