Skip to content

Commit

Permalink
Initialize floss:BluetoothLocalGattDescriptorFloss::cccd_type_
Browse files Browse the repository at this point in the history
BluetoothLowEnergyApiTestChromeOs.NotifyCharacteristicValueChanged fails
when run in MSan mode with eager checks, which validates that uninit
values are not passed as params or return values:

==1002568==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x561d07debefa in floss::BluetoothLocalGattCharacteristicFloss::CccdNotificationType() ./../../device/bluetooth/floss/bluetooth_local_gatt_characteristic_floss.cc:398:1
    #1 0x561d07daf88b in floss::BluetoothAdapterFloss::SendValueChanged(floss::BluetoothLocalGattCharacteristicFloss*, std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>> const&) ./../../device/bluetooth/floss/bluetooth_adapter_floss.cc:1468:23
    #2 0x561d07de5eb7 in floss::BluetoothLocalGattCharacteristicFloss::NotifyValueChanged(device::BluetoothDevice const*, std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>> const&, bool) ./../../device/bluetooth/floss/bluetooth_local_gatt_characteristic_floss.cc:104:34
    #3 0x561cf920f095 in extensions::api::BluetoothLowEnergyNotifyCharacteristicValueChangedFunction::DoWork() ./../../extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc:1427:23
  <...>

  Uninitialized value was created by a heap allocation
    #0 0x561cdea7d49c in operator new(unsigned long) /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/msan/msan_new_delete.cpp:51:35
    #1 0x561d07dede02 in floss::BluetoothLocalGattDescriptorFloss::Create(device::BluetoothUUID const&, unsigned int, floss::BluetoothLocalGattCharacteristicFloss*) ./../../device/bluetooth/floss/bluetooth_local_gatt_descriptor_floss.cc:26:22
    #2 0x561d07de4ce6 in floss::BluetoothLocalGattCharacteristicFloss::Create(device::BluetoothUUID const&, unsigned int, unsigned int, floss::BluetoothLocalGattServiceFloss*) ./../../device/bluetooth/floss/bluetooth_local_gatt_characteristic_floss.cc:35:5
    #3 0x561d07df5fec in floss::BluetoothLocalGattServiceFloss::CreateCharacteristic(device::BluetoothUUID const&, unsigned int, unsigned int) ./../../device/bluetooth/floss/bluetooth_local_gatt_service_floss.cc:142:10
    #4 0x561cf920c91f in extensions::api::BluetoothLowEnergyCreateCharacteristicFunction::DoWork() ./../../extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc:1310:16

Bug: 40240570
Change-Id: I3dd8d46b5750bc881ada08560943151dac294c08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5553870
Reviewed-by: Katherine Lai <[email protected]>
Commit-Queue: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1303901}
  • Loading branch information
zetafunction authored and Chromium LUCI CQ committed May 21, 2024
1 parent 68ab799 commit bac7f6c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattDescriptorFloss
std::vector<uint8_t>& value);

// Notification type of the CCCD.
device::BluetoothGattCharacteristic::NotificationType cccd_type_;
device::BluetoothGattCharacteristic::NotificationType cccd_type_ =
device::BluetoothGattCharacteristic::NotificationType::kNone;

// Cached instance of the latest pending read/write request, if one exists.
std::optional<GattRequest> pending_request_;
Expand Down

0 comments on commit bac7f6c

Please sign in to comment.