StoreProhibited when trying to set callback for BLE

jubueche
Posts: 32
Joined: Sat Jan 19, 2019 4:03 pm

StoreProhibited when trying to set callback for BLE

Postby jubueche » Tue Sep 17, 2019 2:05 pm

Hi,

I have been searching for some days now, but cannot seem to find my mistake. The error happens when I try to set a callback in the BLE class. I checked whether the callback is NULL, but it isn't.
Here is my stack trace:

Code: Select all


D (13343) BLECharacteristic: >> setCallbacks: 0x3ffdba58
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4012c41c  PS      : 0x00060030  A0      : 0x80122868  A1      : 0x3ffbc320  
0x4012c41c: BLECharacteristic::setCallbacks(BLECharacteristicCallbacks*) at /home/julian/Documents/chaze-esp32/components/arduino/libraries/BLE/src/BLECharacteristic.cpp:560

A2      : 0x00000000  A3      : 0x3ffdba58  A4      : 0x3f4149c0  A5      : 0x0000000c  
A6      : 0x00000000  A7      : 0x00000005  A8      : 0x8012c41c  A9      : 0x3ffbc2d0  
A10     : 0x401149b4  A11     : 0x3ffcdb00  A12     : 0x3f4149d4  A13     : 0x0000001f  
0x401149b4: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vprintf.c:35

A14     : 0x00000001  A15     : 0x00000005  SAR     : 0x00000004  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000050  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffb  

ELF file SHA256: a87f7e18600a99461bae758a7fde3b6055f194a08e8a16ba4c24a67ab7ca11aa

Backtrace: 0x4012c41c:0x3ffbc320 0x40122865:0x3ffbc340 0x4010803c:0x3ffbc360 0x400d0b5a:0x3ffbc380 0x400949a1:0x3ffbc3a0
0x4012c41c: BLECharacteristic::setCallbacks(BLECharacteristicCallbacks*) at /home/julian/Documents/chaze-esp32/components/arduino/libraries/BLE/src/BLECharacteristic.cpp:560

0x40122865: connected() at /home/julian/Documents/chaze-esp32/components/Chaze_Connected/Chaze_Connected.cpp:102

0x4010803c: app_main at /home/julian/Documents/chaze-esp32/main/main.cpp:44 (discriminator 8)

0x400d0b5a: main_task at /home/julian/esp/esp-idf/components/esp32/cpu_start.c:542 (discriminator 2)

0x400949a1: vPortTaskWrapper at /home/julian/esp/esp-idf/components/freertos/port.c:143

Here is the code snippet Connected.cpp:102

Code: Select all


void connected()
{
    CONNECTED_STATE = IDLE;
    callback = new ConnectedCallbacks();


    if(callback != NULL)
        ble.pRxCharacteristic->setCallbacks(callback); [Error happens here]
    else
        ESP_LOGE(TAG_Con, "Callback is NULL."); config.STATE = DEEPSLEEP; return;

...
}

where callback is a static variable of type BLECharacteristicCallbacks defined in Advertising.h, which is included in Connected.h.

The line 560 is as follows:

Code: Select all


/**
 * @brief Set the callback handlers for this characteristic.
 * @param [in] pCallbacks An instance of a callbacks structure used to define any callbacks for the characteristic.
 */
void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
	ESP_LOGD(LOG_TAG, ">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
	m_pCallbacks = pCallbacks;
	ESP_LOGD(LOG_TAG, "<< setCallbacks");
} // setCallbacks


Could it be that m_pCallbacks was not initialized since the address EXCVADDR is so close to zero (0x00000050)?

Any help would be appreciated!

jubueche
Posts: 32
Joined: Sat Jan 19, 2019 4:03 pm

Re: StoreProhibited when trying to set callback for BLE

Postby jubueche » Tue Sep 17, 2019 3:16 pm

It looks like the problem is when I am connected, I can not set the callback. It works when I set the callback in the initialization function.

jubueche
Posts: 32
Joined: Sat Jan 19, 2019 4:03 pm

Re: StoreProhibited when trying to set callback for BLE

Postby jubueche » Wed Sep 18, 2019 6:58 am

I used the workaround now by declaring a global variable holding an instance of the MyCallbacks class. I set the callbacks in the initialization process.

glarty
Posts: 3
Joined: Mon Oct 14, 2019 10:50 am

Re: StoreProhibited when trying to set callback for BLE

Postby glarty » Tue Oct 15, 2019 3:45 pm

EXCVADDR: 0x00000050
LoadProhibited, StoreProhibited

This CPU exception happens when application attempts to read from or write to an invalid memory location. The address which was written/read is found in EXCVADDR register in the register dump. If this address is zero, it usually means that application attempted to dereference a NULL pointer. If this address is close to zero, it usually means that application attempted to access member of a structure, but the pointer to the structure was NULL. If this address is something else (garbage value, not in 0x3fxxxxxx - 0x6xxxxxxx range), it likely means that the pointer used to access the data was either not initialized or was corrupted.

I found this problem accessing an array not initialsed that was inside a structure.

Who is online

Users browsing this forum: No registered users and 93 guests