NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

ESP32: Stack canary watchpoint triggered (nimble_host)

Open vicatcu opened this issue 9 months ago • 3 comments

I'm randomly getting this shortly after writing a characteristic value:

Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception). 
Debug exception reason: Stack canary watchpoint triggered (nimble_host)

My free RAM after Bluetooth initialization is complete and advertising is under way, using esp_get_free_heap_size() indicates there are 102672 bytes free...

At a bit of a loss as to what's happening. Any ideas on diagnostics would be appreciated.

vicatcu avatar Mar 31 '25 16:03 vicatcu

I suspect you are doing too much in your callbacks. You can either increase the nimble host task stack size or move your code out of the callbacks and just set a flag or trigger a task (preferred option).

h2zero avatar Mar 31 '25 21:03 h2zero

@vicatcu Any progress on this?

h2zero avatar Apr 24 '25 00:04 h2zero

I suspect you are doing too much in your callbacks. You can either increase the nimble host task stack size or move your code out of the callbacks and just set a flag or trigger a task (preferred option).

I added the following platform.io build flags and it seemed to fix my issue, but I will report back if it happens again:

build_flags =
  -D ARDUINO_NIMBLE
  -D CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=6144

lazd avatar May 25 '25 17:05 lazd

Closing this as resolved.

h2zero avatar Sep 02 '25 20:09 h2zero