New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE::GenericGattClient::DiscoveryControlBlock terminate() called twice #6806

RobMeades opened this Issue May 3, 2018 · 1 comment


None yet
3 participants

RobMeades commented May 3, 2018


  • Type: Bug
  • Priority: Major


nRF52832 (in my case in a UBLOX_EVK_NINA_B1)


mbed-os sha:
0c14ebb (feature-nrf528xx branch)

Expected behavior
BLE::GenericGattClient::DiscoveryControlBlock terminate() should be called once.

Actual behavior
BLE::GenericGattClient::DiscoveryControlBlock terminate() is often called twice. This sometimes results in a hard fault print-out as follows:

++ MbedOS Fault Handler ++

FaultType: HardFault

R0   : 20007A20
R1   : 20007A20
R2   : 0000000A
R3   : 20004158
R4   : 00000000
R5   : 00000000
R6   : 00000000
R7   : 00000000
R8   : 00000000
R9   : 00000000
R10  : 00000000
R11  : 00000000
SP   : 20006CC0
LR   : 00027DF1
PC   : 20004158
xPSR : 000F0000
PSP  : 20006C58
MSP  : 2000FFB0
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000000
BFSR : 00000000
UFSR : 00000002
DFSR : 00000000
AFSR : 00000000
SHCSR: 00000000
Mode : Thread
Priv : Privileged
Stack: PSP

Thread Info:
State: 00000002 EntryFn: 000356E1 Stack Size: 00001000 Mem: 20006068 SP: 20006ED0
State: 00000002 EntryFn: 000356E1 Stack Size: 00001000 Mem: 20006068 SP: 20006ED0
Wait Threads:
State: 00000083 EntryFn: 000398E9 Stack Size: 00000300 Mem: 200051A8 SP: 20005410
Delay Threads:
Idle Thread:
State: 00000001 EntryFn: 000357E9 Stack Size: 00000200 Mem: 20004FA8 SP: 20005090

-- MbedOS Fault Handler --

...where in my case the .map file shows the LR address as being in DiscoveryControlBlock::terminate(GenericGattClient*):

                0x00027db8       0x60 BUILD/UBLOX_EVK_NINA_B1/GCC_ARM/mbed-os/features/FEATURE_BLE/source/generic/GenericGattClient.o
                0x00027db8                ble::generic::GenericGattClient::DiscoveryControlBlock::terminate(ble::generic::GenericGattClient*)
                0x00027e18       0x10 BUILD/UBLOX_EVK_NINA_B1/GCC_ARM/mbed-os/features/FEATURE_BLE/source/generic/GenericGattClient.o
                0x00027e18                ble::generic::GenericGattClient::DiscoveryControlBlock::get_start_handle(ble::pal::AttReadByGroupTypeResponse::attribute_data_t const&)

Other times (e.g. if I happen to be compiling with MBED_HEAP_STATS_ENABLED=1 and MBED_STACK_STATS_ENABLED=1) the printf() in my onServiceDiscoveryTermination handler simply comes out twice, for instance:

Terminated service discovery for handle 0, BLE device 78:48:35:de:cd:19.
Terminated service discovery for handle 0, BLE device 78:48:35:de:cd:19.

Steps to reproduce
Implement a GATT client that attempts to discover the characteristics of BLE devices around you, along the lines of the BLE_LEDBlinker example. Attached is my main.cpp which shows the problem on an UBLOX_EVK_NINA_B1.

@RobMeades RobMeades changed the title from BLE:GenericGattClient::DiscoveryControlBlock terminate() called twice to BLE::GenericGattClient::DiscoveryControlBlock terminate() called twice May 3, 2018


This comment has been minimized.


0xc0170 commented May 4, 2018

@donatieng @pan- Please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment