The `BT_LW_WQ` stack may overflow with the build with debug options selected.
Without build with debug options selected, the thread analyzer shows nearly all of the stack space used:[00:00:31.310,882] <inf> thread_analyzer: BT_LW_WQ : STACK: unused 80 usage 1160 / 1240 (93 %); CPU: 0 %
The configuration option for the stack size is not prompted, so it cannot be overridden to fix the issue without editing the NCS SDK.
config BT_LONG_WQ_STACK_SIZE # Hidden: Long workqueue stack size. Should be derived from system # requirements. int # should have `prompt "Long workqueue stack size"` default 1300 if BT_GATT_CACHING default 1140 if BT_TINYCRYPT_ECC default 1024
I manually edited /opt/nordic/ncs/v2.1.3/zephyr/subsys/bluetooth/host/Kconfig to allow BT_LONG_WQ_STACK_SIZE to be assigned (to 4096) and I no longer experience the stack overflow with the "Enable debug options" flag.
[00:01:01.317,840] <inf> thread_analyzer: BT_LW_WQ : STACK: unused 2776 usage 1256 / 4032 (31 %); CPU: 0 %