buglwIP - A Lightweight TCP/IP stack - Bugs: bug #48953, mdns has rather high stack usage...


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

bug #48953: mdns has rather high stack usage (sizeof(struct mdns_domain)*2)

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Tue 30 Aug 2016 07:29:30 PM UTC
Category:  None Severity:  2 - Minor
Item Group:  Change Request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  git head

Thu 04 Jan 2018 07:07:46 AM UTC, comment #5: 

See also bug #52763 and bug #52770 for discussions related to this.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 10 Mar 2017 10:13:17 PM UTC, comment #4: 

mdns_readname_loop should be fixed (one copy avoided), but the bigger problem of allocating 2 mdns_domain structs on the stack remains. For some parts of the code, allocating those two opne after the other should work, but for some, it's not as easy...

-> changing the summary to reflect this

Simon Goldschmidt <goldsimon>
Group administrator
Thu 15 Dec 2016 09:48:14 PM UTC, comment #3: 

1k might be a little much, but struct mdns_domain (260 bytes) doesn't make it better. I mean if we really need this memory, so be it (rather allocate it on the stack where it's reusable for other code than allocating it seperately), but if we could avoid it it would be better :-)

If we can't avoid it, I'll just close this item, but in that case we should point out the stack requirements (and give a calculation hint) when using the mDNS resolver.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 19 Sep 2016 05:28:48 AM UTC, comment #2: 

On my project, in order to get mDNS to work I had to add about 1k extra stack space to both the TCP/IP thread and my Ethernet input thread (the latter probably due to LWIP_TCPIP_CORE_LOCKING_INPUT).

Daniel Elstner <danielk>
Wed 31 Aug 2016 08:44:30 AM UTC, comment #1: 

This is mentioned in the documentation that it uses some stack.

Many of the answer writing functions (mdns_add_XXXXX_answer) have two mdns_domain structs on the stack (259 or so bytes each)

Erik Ekman <yarrick>
Group Member
Tue 30 Aug 2016 07:29:30 PM UTC, original submission:  

mdns_readname_loop() decodes a DNS name (this is kind of duplicate to what dns.c does, already, so might be merged?).
However, when doing so, it allocates a 63 byte array on the stack. This is rather not the coding style lwIP has had so far: the stack has so far tried to keep stack usage minimal...

Simon Goldschmidt <goldsimon>
Group administrator


(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 danielk (Posted a comment)
  • -email is unavailable- added by yarrick (Posted a comment)
  • -email is unavailable- added by goldsimon (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.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-03-10 goldsimon Severity3 - Normal 2 - Minor
        Summarymdns_readname_loop() allocates rather big array on the stack mdns has rather high stack usage (sizeof(struct mdns_domain)*2)

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code