Photon hangs after 'System.freeMemory' call when not connected to cloud

Photon hangs when ‘System.freeMemory’ is called in user application and the device is not connected to the cloud.

For replication overwrite the server key+address on the photon so that it wouldn’t be able to connect to the cloud. Edit the default tinker application by adding the line ‘System.freeMemory()’ to the main loop and program the photon. After a few cloud connection retries the photon LED stops in a constant cyan state and the user application is not executed any further.

gdb backtrace:

#0  0x08024e8a in vListInsert (pxList=pxList@entry=0x2000c94c, pxNewListItem=0x2000f148) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/list.c:171
#1  0x08025a76 in vTaskPlaceOnEventList (pxEventList=pxEventList@entry=0x2000c94c, xTicksToWait=4294967295) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/tasks.c:1980
#2  0x080252dc in xQueueGenericReceive (xQueue=xQueue@entry=0x2000c928, pvBuffer=pvBuffer@entry=0x0, xTicksToWait=xTicksToWait@entry=4294967295, xJustPeeking=xJustPeeking@entry=0) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/queue.c:1164
#3  0x08025378 in xQueueTakeMutexRecursive (xMutex=0x2000c928, xBlockTime=xBlockTime@entry=4294967295) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/queue.c:507
#4  0x0802d1da in __malloc_lock (ptr=<optimized out>) at WICED/RTOS/FreeRTOS/WICED/wiced_rtos.c:475
#5  0x08031888 in _malloc_r (reent_ptr=0x20000724 <impure_data>, s=<optimized out>) at src/mallocr.c:274
#6  0x08025fea in pvPortMalloc (xWantedSize=xWantedSize@entry=76) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/portable/MemMang/heap_3.c:95
#7  0x08025028 in xQueueGenericCreate (uxQueueLength=uxQueueLength@entry=1, uxItemSize=uxItemSize@entry=0, ucQueueType=ucQueueType@entry=3 '\003') at WICED/RTOS/FreeRTOS/ver7.5.2/Source/queue.c:296
#8  0x08031704 in sys_sem_new (sem=sem@entry=0x20005be4 <memp_memory_NETCONN_base+828>, count=count@entry=0 '\000') at WICED/network/LwIP/WWD/FreeRTOS/sys_arch.c:228
#9  0x08026b5a in netconn_alloc (t=<optimized out>, callback=callback@entry=0x0) at WICED/network/LwIP/ver1.4.0.rc1/src/api/api_msg.c:598
#10 0x08026224 in netconn_new_with_proto_and_callback (t=t@entry=NETCONN_UDP, proto=proto@entry=0 '\000', callback=callback@entry=0x0) at WICED/network/LwIP/ver1.4.0.rc1/src/api/api_lib.c:73
#11 0x0802dfbe in wiced_udp_create_socket (socket=socket@entry=0x2000fd58, port=port@entry=0, interface=interface@entry=WICED_STA_INTERFACE) at WICED/network/LwIP/WICED/tcpip.c:747
#12 0x080238c4 in dns_client_hostname_lookup (hostname=0x2000fdc8 "test-cloud.globalreader.eu", address=0x2000fda4, timeout_ms=5000) at libraries/protocols/DNS/dns.c:132
#13 0x0803652c in inet_gethostbyname (hostname=<optimized out>, hostnameLen=<optimized out>, out_ip_addr=0x2000fe64, nif=<optimized out>, reserved=0x0) at src/photon/inet_hal.cpp:32
#14 0x0803b19c in determine_connection_address (ip_addr=..., port=@0x2000fe4e: 5683, server_addr=..., udp=udp@entry=false) at src/system_cloud_internal.cpp:794
#15 0x0803b218 in Spark_Connect () at src/system_cloud_internal.cpp:858
#16 0x0803a77c in establish_cloud_connection () at src/system_task.cpp:215
#17 0x0803aac8 in manage_cloud_connection (force_events=<optimized out>) at src/system_task.cpp:302
#18 0x0803ab02 in Spark_Idle_Events (force_events=<optimized out>) at src/system_task.cpp:333
#19 0x0803966c in ActiveObjectBase::run (this=0x200091c4 <SystemThread>) at src/active_object.cpp:49
#20 0x0803968c in ActiveObjectBase::run_active_object (object=<optimized out>) at src/active_object.cpp:74
#21 0x08038f78 in std::invoke_thread (ptr=0x2000c8b8) at src/system_threading.cpp:89
#22 0x00000000 in ?? ()
(gdb) fin
Run till exit from #0  0x08024e8a in vListInsert (pxList=pxList@entry=0x2000c94c, pxNewListItem=0x2000f148) at WICED/RTOS/FreeRTOS/ver7.5.2/Source/list.c:171

Many thanks for this. We’ve also seen this in other circumstances, we are investigating this now with urgency!

1 Like