New issue
Advanced search Search tips

Issue 644321 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Bluetooth OnGetGattEventWin call back function has wrong calling convention

Project Member Reported by brucedaw...@chromium.org, Sep 6 2016

Issue description

Prior to the Windows 10.0.14393 SDK the PFNBLUETOOTH_GATT_EVENT_CALLBACK typedef was incorrect which led to code that defined these callback functions to omit the CALLBACK calling convention modifier. This can lead to stack misalignment, and it also makes Chrome not compile with the Windows 10.0.14393 SDK.

This article discusses the potential consequences of this bug:

http://www.busydevelopers.com/article/43503478/Program+crashed+after+recived+Bluetooth+LE+Notification
 
Cc: scottmg@chromium.org
Huh, I thought we had a custom typedef to avoid that before.

... hmm, https://chromium.googlesource.com/chromium/src/+log/master/device/bluetooth/bluetooth_low_energy_defs_win.h

I guess we didn't use to actually need the callback declaration, at least when we updated to 2013U4. Maybe.
It looks like that was a different bluetooth declaration bug - mismatched pragma warning push/pop directives. I'm seeing a theme here - maybe the bluetooth at Microsoft team needs better testing?

I was looking at the original here https://codereview.chromium.org/395633003/diff/40001/device/bluetooth/bluetooth_low_energy_defs_win.h which we used to avoid the header.

But yes, the quality control on that header seems questionable anyway.
Project Member

Comment 4 by bugdroid1@chromium.org, Sep 13 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2181e0ecc3172fc2a5f4eee62a125f784f5993f5

commit 2181e0ecc3172fc2a5f4eee62a125f784f5993f5
Author: brucedawson <brucedawson@chromium.org>
Date: Tue Sep 13 01:53:39 2016

Fix bluetooth callback function declaration

The PFNBLUETOOTH_GATT_EVENT_CALLBACK typedef has been incorrect for
years and was fixed in the Windows 10.0.14393 SDK. This leads to
compile errors when building with this SDK. The incorrect function
declaration is missing CALLBACK which can lead to stack mismatches
so fixing the code to use the new declaration is important. A fixed
typedef needs to be used throughout Chromium to ensure consistent
stack cleanup. A cast is needed when calling into Windows (so that
Chrome will continue to build with the Windows 10.0.10586 SDK) and
that is the only time that the SDK supplied typedef should be used.

BUG= 644321 

Review-Url: https://codereview.chromium.org/2317773002
Cr-Commit-Position: refs/heads/master@{#418138}

[modify] https://crrev.com/2181e0ecc3172fc2a5f4eee62a125f784f5993f5/device/bluetooth/bluetooth_low_energy_win.cc
[modify] https://crrev.com/2181e0ecc3172fc2a5f4eee62a125f784f5993f5/device/bluetooth/bluetooth_low_energy_win.h
[modify] https://crrev.com/2181e0ecc3172fc2a5f4eee62a125f784f5993f5/device/bluetooth/bluetooth_low_energy_win_fake.cc
[modify] https://crrev.com/2181e0ecc3172fc2a5f4eee62a125f784f5993f5/device/bluetooth/bluetooth_low_energy_win_fake.h
[modify] https://crrev.com/2181e0ecc3172fc2a5f4eee62a125f784f5993f5/device/bluetooth/bluetooth_task_manager_win.cc

Status: Fixed (was: Started)
Our callback is now correct, and we now build with either 10.0.10586 or 10.0.14393 SDKs.

Sign in to add a comment