Skip to content

netutils/mdns: raise responder stack size default to 8KiB#3630

Open
ricardgb wants to merge 1 commit into
apache:masterfrom
ricardgb:mdns-stacksize-default
Open

netutils/mdns: raise responder stack size default to 8KiB#3630
ricardgb wants to merge 1 commit into
apache:masterfrom
ricardgb:mdns-stacksize-default

Conversation

@ricardgb

@ricardgb ricardgb commented Jul 11, 2026

Copy link
Copy Markdown

Summary

CONFIG_NETUTILS_MDNS_STACKSIZE defaulted to DEFAULT_TASK_STACKSIZE,
which resolves to as little as 2KiB on some targets. The bundled mjansson
mDNS responder needs a deeper stack than that — DNS record parsing with
name decompression, plus the send/receive buffers — so on those targets it
overflows its stack and hardfaults at startup, before it can answer a
single query.

This raises the default to 8KiB (the value that reliably runs the
responder) and corrects the help text, which previously claimed a "4KiB"
default that did not match DEFAULT_TASK_STACKSIZE.

Impact

  • Fixes a startup hardfault when the mDNS app/daemon is enabled on targets
    with a small DEFAULT_TASK_STACKSIZE.
  • No API change; configurations that already set an explicit stack size are
    unaffected.

Testing

Reproduced and fixed on a Raspberry Pi Pico 2 W (RP2350, NuttX). With the
old default (2KiB on this target) the responder overflowed its stack and
hardfaulted at startup; with the new 8KiB default it runs and answers mDNS
queries normally (verified with avahi-resolve/avahi-browse from a host).

Here are on-hardware test logs from a Raspberry Pi Pico 2 W (RP2350), NuttX 13.0.0-RC0.

The mDNS responder was built with CONFIG_NETUTILS_MDNS_STACKSIZE=8192 — the value this PR makes the default — and run over a USB CDC-NCM link (board eth0 192.168.7.1 ⇆ Linux host usb0 192.168.7.2).

Board — responder starts and answers a live query:

nsh> mdnsd_start
Local IPv4 address: 192.168.7.1
Opened 1 socket for mDNS service
Service mDNS: _http._tcp.local.:80
Hostname: nuttx
Sending announce
...
Query PTR _http._tcp.local.
  --> answer nuttx._http._tcp.local. (multicast)

Board — responder task running at the 8 KiB stack, no overflow (ps):

  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK          STACK COMMAND
    8     8     0 100 RR       Task      - Waiting  Semaphore 000...0000       0008080 --service _http._tcp.local --hostname nuttx --port 80

(The responder task shows an ~8 KiB stack; other tasks are ~2 KiB.)

Host — discovery / resolution / reachability:

$ avahi-browse -rt _http._tcp
=   usb0 IPv4 nuttx                     Web Site         local
   hostname = [nuttx.local]
   address = [192.168.7.1]
   port = [80]
   txt = ["other=value" "test=1"]

$ avahi-resolve -n nuttx.local
nuttx.local	192.168.7.1

$ ping nuttx.local          # name resolved via the board's responder
64 bytes from 192.168.7.1: icmp_seq=3 ttl=64 time=16.9 ms
3 packets transmitted, 3 received, 0% packet loss

The responder runs, advertises, and answers queries at the 8 KiB stack without overflowing.


Disclosure: this change was prepared by an AI agent (Claude Code) at the
direction of the author (@ricardgb), who reviewed it before submission.

🤖 Generated with Claude Code

@Abhishekmishra2808

Copy link
Copy Markdown
Contributor

@ricardgb, please sign your commit message with git commit -s (https://nuttx.apache.org/docs/latest/contributing/guide.html#commit-requirements).
Also, rebase the branch; then the checks will pass.

@ricardgb
ricardgb force-pushed the mdns-stacksize-default branch from d4716e0 to d024b03 Compare July 11, 2026 16:12

@linguini1 linguini1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Assisted-by: field from the contribution guide. Also, please attach your test logs from your testing on the Pico.

CONFIG_NETUTILS_MDNS_STACKSIZE defaulted to DEFAULT_TASK_STACKSIZE,
which resolves to as little as 2KiB on some targets.  The bundled
mjansson responder uses a deeper stack than that (DNS record parsing
with name decompression, plus the send/receive buffers) and overflows
on startup, taking the board down with a hardfault before it answers a
single query.

Default to 8KiB, the value that reliably runs the responder, and
correct the help text, which previously claimed a 4KiB default that did
not match DEFAULT_TASK_STACKSIZE.

Assisted-by: Claude (Anthropic Claude Code)
Signed-off-by: Ricard Rosson <ricard@groundbits.com>
@ricardgb
ricardgb force-pushed the mdns-stacksize-default branch from d024b03 to 693aeaa Compare July 23, 2026 15:51
@ricardgb

Copy link
Copy Markdown
Author

@linguini1 commit trailer updated to Assisted-by: per the contribution guide (and rebased onto the latest master). Test logs from the Pico will follow in a separate comment.

@ricardgb

Copy link
Copy Markdown
Author

@linguini1 here are on-hardware test logs from a Raspberry Pi Pico 2 W (RP2350), NuttX 13.0.0-RC0.

The mDNS responder was built with CONFIG_NETUTILS_MDNS_STACKSIZE=8192 — the value this PR makes the default — and run over a USB CDC-NCM link (board eth0 192.168.7.1 ⇆ Linux host usb0 192.168.7.2).

Board — responder starts and answers a live query:

nsh> mdnsd_start
Local IPv4 address: 192.168.7.1
Opened 1 socket for mDNS service
Service mDNS: _http._tcp.local.:80
Hostname: nuttx
Sending announce
...
Query PTR _http._tcp.local.
  --> answer nuttx._http._tcp.local. (multicast)

Board — responder task running at the 8 KiB stack, no overflow (ps):

  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK          STACK COMMAND
    8     8     0 100 RR       Task      - Waiting  Semaphore 000...0000       0008080 --service _http._tcp.local --hostname nuttx --port 80

(The responder task shows an ~8 KiB stack; other tasks are ~2 KiB.)

Host — discovery / resolution / reachability:

$ avahi-browse -rt _http._tcp
=   usb0 IPv4 nuttx                     Web Site         local
   hostname = [nuttx.local]
   address = [192.168.7.1]
   port = [80]
   txt = ["other=value" "test=1"]

$ avahi-resolve -n nuttx.local
nuttx.local	192.168.7.1

$ ping nuttx.local          # name resolved via the board's responder
64 bytes from 192.168.7.1: icmp_seq=3 ttl=64 time=16.9 ms
3 packets transmitted, 3 received, 0% packet loss

The responder runs, advertises, and answers queries at the 8 KiB stack without overflowing.

Disclosure: these tests were run and captured with the help of an AI agent (Claude Code, Anthropic); results are from real hardware and human-reviewed.

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ricardgb :-) Please remember to always attach test logs to the PR description, before the problem (segfault) and after (showing fix working).. I have copy-pasted it to the PR description from a discussion :-)

Comment thread netutils/mdns/Kconfig
attached that could send queries.
Stack size for the mDNS responder task. The bundled mjansson
responder uses a fairly deep stack (record parsing with name
decompression plus the send/receive buffers), so the previous

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a description of the problem in the help message? The option description should describe the options and that's it. Please look more closely at what Claude generates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants