LEAmDNS: _parseResponse keeps every answer record of a packet on the heap, so one large answer can abort with out of memory
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- arduino, cpp
- 领域
- embedded-iot
调研方向
Start in libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp: trace _parseResponse through _readRRAnswer and _processAnswers, then compare with _parseQuery's record handling. The report proposes processing and freeing each response record before reading the next; done means response handling no longer retains all packet records at once while preserving probe and service query behavior. The reporter says they have a patched copy, but provides no test or captured packet.
由索引模型根据 Issue 内容生成。
描述
What happens
An ESP8266 (core 3.1.2, a GeekMagic SmallTV-Ultra with about 6 KB of free heap while running) restarted after
11.4 hours with an out-of-memory abort inside LEAmDNS. Our crash record, decoded with addr2line:
operator new (288 bytes) failed
<- MDNSResponder::_readRRAnswer
<- MDNSResponder::_parseResponse
<- MDNSResponder::_parseMessage
<- MDNSResponder::_process
free heap 952 bytes, largest free block 248 bytes
The lowest values recorded before, during those hours, were about 4.4 KB free and a 1.5 KB largest block. So
about 3.5 KB went within a moment. The sketch only advertises (MDNS.begin, addService, addServiceTxt, and
MDNS.update() in loop()); it sends no queries.
Why, from reading the code (master, libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp)
_parseResponsereads answers only while a service query waits or a probe runs (line 742-743). Probing runs
afterMDNS.beginand again after every interface status change (LEAmDNS.cpp, thestatusChangeCBthat
calls_restart()), for example a Wi-Fi reconnect.- In that state, every record of the incoming packet (
ANCount + NSCount + ARCount, taken from the packet
header) is read with_readRRAnswerinto its own heap object and kept in a list (lines 764-775). - The list goes to
_processAnswersas a whole (line 794) and is freed only after that (lines 804-810).
So the heap needed grows with the number of records in someone else's answer. A phone, TV or speaker that
answers with many records during the probe window can take several KB at once. new aborts on failure in this
core, so the library's own checks for a failed allocation never run, and the result is a restart.
What we did not measure: we have not captured the packet, and we don't know for sure that a reconnect came just
before. That part is our reading of the code.
_parseQuery handles known answers differently: it frees each record right after reading it (so one record at a
time), which is why we think the same can work for responses.
Possible fix
Handle each answer record in _parseResponse as soon as it is read, and free it before reading the next, so the
peak is one record instead of the whole packet. That means splitting _processAnswers so it can take one record
at a time. A simpler, partial alternative: skip (read past without allocating) records whose names cannot
concern this responder.
We are trying the first approach in a patched copy for our own firmware and can open a PR if this direction is
welcome.
- 主要语言
- C++
- 星标
- 16.7k
- 派生
- 13k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 7
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
esp8266/Arduino 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
esp8266/Arduino#9342 · 2 条评论 ·
维护者通常 1 天内回复
-
Typo in Scan Class Documentation可能已有人在做 @MukundaKatta 于 207 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
esp8266/Arduino#9203 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 65/100
esp8266/Arduino#9324 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
相似的 Issue
-
status:needs-triage
难度 2/5 1-3 小时 新手友好度 74/100
PX4/PX4-Autopilot#29698 ·
维护者通常 1 天内回复
-
go perft exits when EvalFile is unavailable可能已有人在做 @Muawiya-contact 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
official-stockfish/Stockfish#7292 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
arvidn/libtorrent#9149 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
rhalbersma/tabula#72 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复