This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Assert in entry_validation()

When running the light_switch_provisioner example built on my machine, it crashes on an assert in entry_validation() in mesh_config.c:

app_error_weak.c,   95, Mesh assert at 0x00031EAE (:0)

The problem is that the iteration over the config entries doesn't stop at the end of the list because the pointer comparison in NRF_MESH_SECTION_FOR_EACH (nrf_mesh_section.h) never comes true. This looked like a compiler bug for a while, but the C99 standard actually doesn't guarantee that random pointers can be compared like this. See http://port70.net/~nsz/c/c11/n1570.html#6.5.9p6.

This patch makes it work, because it makes the comparison on integers instead of pointers:

diff --git a/nordic/nrf5_SDK_for_Mesh/mesh/core/api/nrf_mesh_section.h b/nordic/nrf5_SDK_for_Mesh/mesh/core/api/nrf_mesh_section.h
index 1aeed98..0fa8c2d 100644
--- a/nordic/nrf5_SDK_for_Mesh/mesh/core/api/nrf_mesh_section.h
+++ b/nordic/nrf5_SDK_for_Mesh/mesh/core/api/nrf_mesh_section.h
@@ -98,7 +98,7 @@
 
 #define NRF_MESH_SECTION_FOR_EACH(section_name, data_type, variable)                               \
     for (data_type * variable = (data_type *) NRF_MESH_SECTION_START(section_name);                \
-         variable != (data_type *) NRF_MESH_SECTION_END(section_name);                             \
+         (intptr_t)variable != (intptr_t) NRF_MESH_SECTION_END(section_name);                             \
          variable++)
 
 /** @} */

My setup is Fedora 28, compiler arm-none-eabi-gcc (Fedora 7.1.0-5.fc27) 7.1.0. Using the PCA10040 devkit. Using nrf5_SDK_for_Mesh_v2.2.0.

Parents Reply Children
Related