buglwIP - A Lightweight TCP/IP stack - Bugs: bug #64909, No memory pool MEMP_SYS_TIMEOUT...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #64909: No memory pool MEMP_SYS_TIMEOUT allocation for SNTP timer

Submitter:  Richard Lang <richardlang>
Submitted:  Sun 19 Nov 2023 08:53:41 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Crash Error Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.3

Wed 19 Jun 2024 10:00:07 AM UTC, comment #3: 

Addendum:

  5. Note in documentation why a user might want to set MEMP_ADD_NUM_SYS_TIMEOUT.

Steps 4 & 5 are assuming there remains some reason to even allow MEMP_NUM_SYS_TIMEOUT to differ from LWIP_NUM_SYS_TIMEOUT_INTERNAL, after implementing steps 1-3.

Brendan McDonnell <brendan_mod_emb>
Wed 19 Jun 2024 02:24:48 AM UTC, comment #2: 


> there doesn't seem to be any allowance for the SNTP timer.  SNTP support is conditionally included based on LWIP_UDP so I'd expect the above declaration should be
>
>  #define LWIP_NUM_SYS_TIMEOUT_INTERNAL   (LWIP_TCP + LWIP_UDP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))

I agree with your assessment. I think your proposal is part of the solution.
Searching the code (at commit 86c9f799, which is a descendent of STABLE-2_2_0_RELEASE), I find:

$ git grep -w MEMP_NUM_SYS_TIMEOUT | grep -i increase
doc/mqtt_client.txt:You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use MQTT!
src/apps/mdns/mdns.c: * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use MDNS!
src/apps/sntp/sntp.c: * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use SNTP!
src/apps/tftp/tftp.c: * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use TFTP!


So there are several lwIP "apps" which say that if you use them, you must "increase" MEMP_NUM_SYS_TIMEOUT, but lwIP provides no way to increase it relative to the default value (LWIP_NUM_SYS_TIMEOUT_INTERNAL). The only thing the user application can do is #define its own absolute value for MEMP_NUM_SYS_TIMEOUT (since LWIP_NUM_SYS_TIMEOUT_INTERNAL isn't exposed). But later if the user enables/uses more lwIP apps w/o remembering to also increase their MEMP_NUM_SYS_TIMEOUT, it will break.

IMO, a proper solution to this issue would include:

  1. #defines to enable/disable the lwIP apps found by my grep above (mqtt, mdns, sntp, tftp)
  2. Add those #defines as part of the calculation for the value of LWIP_NUM_SYS_TIMEOUT_INTERNAL (similar to as suggested in the original submission)
  3. Remove those lines found by my grep above from the documentation
  4. Probably also provide a new #define (e.g. MEMP_ADD_NUM_SYS_TIMEOUT), default value 0, which the user can optionally override. Then change MEMP_NUM_SYS_TIMEOUT definition to


  #define  MEMP_NUM_SYS_TIMEOUT  (LWIP_NUM_SYS_TIMEOUT_INTERNAL + MEMP_ADD_NUM_SYS_TIMEOUT)


Brendan McDonnell <brendan_mod_emb>
Thu 11 Apr 2024 02:22:23 PM UTC, comment #1: 

Same issue also in git head version
I have also another issue
https://savannah.nongnu.org/bugs/?65582

In my opinion we need to do every time
sys_untimeout(sntp_request, NULL);
sys_untimeout(sntp_try_next_server, NULL);
before calling sys_timeout

Michele

Michele Da Rold <micheledarold>
Sun 19 Nov 2023 08:53:41 PM UTC, original submission:  

Configured LWIP with pretty much default options apart from TCP/IP and sockets API disabled (UDP enabled, no DNS, DHCP etc).  Under these circumstances the LWIP_NUM_SYS_TIMEOUT_INTERNAL declaration in "./src/include/lwip/opt.h" evaluates to 2.

On trying to initialise the SNTP module with sntp_init() call, the sys_timeout() call within sntp_send_request() fails to find an available memory pool entry in MEMP_SYS_TIMEOUT pool and returns a NULL pointer, triggering the subsequent LWIP_ASSERT() statement.

looking at "opt.h"

  #define LWIP_NUM_SYS_TIMEOUT_INTERNAL   (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))

there doesn't seem to be any allowance for the SNTP timer.  SNTP support is conditionally included based on LWIP_UDP so I'd expect the above declaration should be

  #define LWIP_NUM_SYS_TIMEOUT_INTERNAL   (LWIP_TCP + LWIP_UDP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))




Encountered on 2.1.3 branch, but examination of declaration in master looks to me as though problem still exists.

Richard Lang <richardlang>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by brendan_mod_emb (Posted a comment)
  • -email is unavailable- added by micheledarold (Posted a comment)
  • -email is unavailable- added by richardlang (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.14-3b9d.
    Corresponding source code