[b2g-bluetooth] Calling setEnabled(false) twice in a very short period may crash

RESOLVED FIXED in mozilla17

Status

()

Core
DOM: Device Interfaces
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: ericchou, Assigned: ericchou)

Tracking

unspecified
mozilla17
ARM
Gonk (Firefox OS)
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
Evelyn found a bug: If BluetoothManager.setEnabled(false) is called twice almost at the same time, it may lead to system crash.

I've checked and found the root cause. In class ToggleBtAck, we try to shutdown gBluetoothService->mBluetoothCommandThread. When the second setEnabled(false) is called, mBluetoothCommandThread may have been swapped by the first setEnabled, which means that gBluetoothService->mBluetoothCommandThread will be null.

The easiest and efficient way to solve this is to add an if-statement to ensure mBluetoothCommandThread is not null.
(Assignee)

Updated

5 years ago
Assignee: nobody → echou
(Assignee)

Comment 1

5 years ago
Created attachment 652056 [details] [diff] [review]
v1: Check if mBluetoothCommandThread is null
Attachment #652056 - Flags: review?(kyle)
Comment on attachment 652056 [details] [diff] [review]
v1: Check if mBluetoothCommandThread is null

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

r=me, I think this should work, though we should probably have bent take a look at this before it lands since this is totally a regression I caused when we landed 768306, where I removed the reference counting. :/
Attachment #652056 - Flags: review?(kyle)
Attachment #652056 - Flags: review+
Attachment #652056 - Flags: feedback?(bent.mozilla)
Comment on attachment 652056 [details] [diff] [review]
v1: Check if mBluetoothCommandThread is null

Ok, bent's out this week, and I'm mostly sure this should work at least for the moment. Will file a followup to talk to bent about this when he gets back. Landable for now.
Attachment #652056 - Flags: feedback?(bent.mozilla)
(Assignee)

Comment 4

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/cb192b83831c
https://hg.mozilla.org/mozilla-central/rev/cb192b83831c
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.