Closed Bug 782905 Opened 7 years ago Closed 7 years ago

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

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: echou, Assigned: echou)

Details

Attachments

(1 file)

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: nobody → echou
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)
https://hg.mozilla.org/mozilla-central/rev/cb192b83831c
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.