You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate potential cross-task race in bus configuration handoff #6029
Investigate and fix a possible pre-existing cross-task race in the handoff of LED bus configurations. This issue was identified during review of PR #6026 and is outside that PR's scope.
Affected code
wled00/set.cpp: handleSettingsSet() appends to busConfigs, fills each BusConfig, and then sets doInitBusses.
wled00/wled.cpp: WLED::loop() consumes doInitBusses and calls strip.finalizeInit().
wled00/FX_fcn.cpp: WS2812FX::finalizeInit() iterates busConfigs, then clears and shrinks the vector.
wled00/cfg.cpp: configuration deserialization also modifies busConfigs and doInitBusses; include its call paths in the audit.
wled00/wled.h: declares the shared vector and flag.
If a later settings update modifies the vector while the loop consumes it, vector storage or references could be invalidated. The existing flag handoff does not by itself protect the vector from a subsequent concurrent update. This is a possible memory-safety issue; no crash has been reproduced in this review.
Required work
Audit task ownership and synchronization for all producers and consumers of busConfigs and doInitBusses.
Ensure that the loop receives a complete, stable configuration and that concurrent updates cannot invalidate the vector or lose an initialization request. Protect the data and its handoff, not only the flag.
Add or run a regression check that exercises repeated or overlapping LED settings updates while bus initialization is in progress. Document the test and results.
changed the title [-]Investigate cross-task race in bus configuration handoff[/-][+]Investigate potential cross-task race in bus configuration handoff[/+]on Dec 3, 2026
#!/bin/bashset -o pipefail
echo'--- revision ---'
git rev-parse HEAD
echo'--- source windows ---'forspecin'wled00/set.cpp:110:155''wled00/set.cpp:195:340''wled00/set.cpp:450:474''wled00/wled.cpp:59:100''wled00/wled.cpp:210:270''wled00/FX_fcn.cpp:1315:1405''wled00/wled_server.cpp:745:820''wled00/cfg.cpp:40:65''wled00/cfg.cpp:198:300';do
IFS=: read -r file first last <<<"$spec"echo"=== $file:$first-$last ==="
cat -n "$file"| sed -n "${first},${last}p"doneecho'--- request and config paths ---'
rg -n -C 4 '\b(deserializeConfig|deserializeConfigFromFS|handleSettingsSet|SUBPAGE_LEDS|requestJSONBufferLock|releaseJSONBufferLock)\b' wled00 --glob '*.{h,cpp}' -g '!src/dependencies/**'echo'--- bus teardown and add outlines ---'
ast-grep outline wled00/bus_manager.cpp --items all --match 'add|removeAll|allocateHardware|BusDigital'
rg -n -C 4 '\b(BusManager::add|BusManager::removeAll|BusManager::allocateHardware|BusDigital::BusDigital)\s*\(' wled00/bus_manager.cpp
echo'--- async web library and processor definitions ---'
rg -n -C 2 -i 'espasyncwebserver|asynctcp|esp8266asynctcp|async_tcp|config_async_tcp|CONFIG_FREERTOS_HZ' platformio.ini wled00 --glob '*.{ini,h,cpp}' -g '!src/dependencies/**'| head -160
Length of output: 76743
Script executed:
#!/bin/bashset -o pipefail
echo'--- JSON route and lock ---'
cat -n wled00/wled_server.cpp | sed -n '405,462p'
cat -n wled00/util.cpp | sed -n '284,333p;700,756p'echo'--- finalizeInit timing dependencies ---'
cat -n wled00/bus_manager.cpp | sed -n '330,354p;1508,1565p;1600,1645p'
rg -n -C 4 '\bcanAllShow\s*\(|\bcanShow\s*\(' wled00/bus_manager.h wled00/bus_manager.cpp wled00/FX_fcn.cpp
echo'--- protocol timing constants ---'
rg -n -i -C 2 '800 ?k[hH]z|1250 ?ns|t0h|t1h|TYPE_WS2812_RGB|WS2812.*(speed|timing|us|MHz)' wled00/bus_config.h wled00/bus_manager.cpp wled00/const.h | head -180
echo'--- relevant web form submission route ---'
rg -n -C 3 'action=.*(settings|leds)|settings/leds|sett/leds|/json/cfg' wled00/data wled00/wled_server.cpp | head -100
Length of output: 27231
@DedeHai Here is a possible ESP32 interleaving with two LED settings requests. The times are illustrative, not measurements.
Assume an existing 300-pixel WS2812 RGB bus is transmitting when the first request completes. At 800 kbit/s, its 24 bits per pixel take about 9 ms to transmit, plus latch time.
Time
Event
0 ms
Request A finishes populating busConfigs and sets doInitBusses = true.
1 ms
WLED::loop() clears the flag and enters finalizeInit(). Assume removeAll() must wait about 7 ms for the current frame.
2–3 ms
Request B appends its configurations to the same vector and sets doInitBusses = true. This assumes the request finishes during the wait.
8 ms
The loop continues, constructs buses from the combined A and B entries, then clears busConfigs.
Later
The loop sees B’s flag and calls finalizeInit() again. If the vector is still empty, that call removes the buses and constructs none.
If request B instead appends during vector iteration, reallocation could invalidate the loop’s references. That requires a narrower overlap than the example above.
The 9 ms is a wire-time estimate, not a measured race window. The actual wait and request duration depend on the driver, frame phase, configuration, and scheduling. I have not reproduced this failure. To establish the window, timestamp the flag writes, removeAll() wait, vector appends, iterations, and clear during repeated requests.
Learnings used
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
Prefer compact function parameter lists and `if` conditions rather than putting each parameter or condition part on its own line. Wrap parameter lists only when they become very long.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:24:49.630Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
Whether the opening bracket of e.g. an `if` block is in the same line as the condition or in a separate line is up to your discretion. If there is only one statement, leaving out block brackets is acceptable.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
There should always be a space between a keyword and its condition and between the condition and brace.
Within the condition, no space should be between the parenthesis and variables.
Spaces between variables and operators are up to the authors discretion.
There should be no space between function names and their argument parenthesis.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:24:49.630Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Source Code from an AI agent or bot
#### Best Practice with AI
- ✅ **Be transparent** - Add comments `// AI: below section was generated by an AI` ... `// AI: end` around larger chunks
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Comments
There is no hard character limit for a comment within a line,
though as a rule of thumb consider wrapping after 120 characters.
Inline comments are OK if they describe that line only and are not exceedingly wide.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Comments
Comments should have a space between the delimiting characters (e.g. `//`) and the comment text.
We're gradually adopting this style - don't worry if you see older code without spaces!
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
Don't stress too much about style! When in doubt, just match the style in the files you're editing. 😊
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/common.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/iro.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
#!/bin/bashset -o pipefail
echo'--- revision and instructions ---'
git rev-parse HEAD
if [ -f AGENTS.md ];then cat -n AGENTS.md | sed -n '1,160p';fiecho'--- issue ---'
gh api repos/wled/WLED/issues/6029 --jq '{title,body,state,html_url}'echo'--- symbol references ---'
rg -n -C 3 '\b(busConfigs|doInitBusses|finalizeInit|handleSettingsSet|deserializeConfig)\b' wled00 --glob '*.{cpp,h}'echo'--- candidate outlines ---'forfin wled00/set.cpp wled00/wled.cpp wled00/FX_fcn.cpp wled00/cfg.cpp wled00/wled_server.cpp wled00/bus_manager.cpp;doecho"=== $f ==="
ast-grep outline "$f" --items all --match 'handleSettingsSet|finalizeInit|deserializeConfig|removeAll|onBody|onRequest|WLED'||truedoneecho'--- cited windows ---'forspecin'wled00/set.cpp:195:310''wled00/set.cpp:450:480''wled00/wled.cpp:220:250''wled00/FX_fcn.cpp:1320:1385''wled00/bus_manager.cpp:1510:1575''wled00/cfg.cpp:190:300''wled00/wled_server.cpp:405:465''wled00/wled_server.cpp:740:820';do
IFS=: read -r file first last <<<"$spec"echo"=== $file Lines $first-$last ==="
cat -n "$file"| sed -n "${first},${last}p"done
Length of output: 59375
Script executed:
#!/bin/bashset -o pipefail
echo'--- lock, enumeration, routing, and teardown references ---'
rg -n -C 4 '\b(enumerateLedmaps|requestJSONBufferLock|releaseJSONBufferLock|deserializeConfigFromFS|AsyncCallbackJsonWebHandler|removeAll|canAllShow)\b' wled00 --glob '*.{cpp,h}'| head -350
echo'--- outlines for related code ---'
ast-grep outline wled00/util.cpp --items all --match 'enumerateLedmaps|requestJSONBufferLock|releaseJSONBufferLock'||true
ast-grep outline wled00/bus_manager.cpp --items all --match 'removeAll|canAllShow'||true
ast-grep outline wled00/wled_server.cpp --items all --match 'serveSettings|initServer'||trueecho'--- teardown and dispatch ---'
cat -n wled00/bus_manager.cpp | sed -n '1595,1650p'
cat -n wled00/wled_server.cpp | sed -n '465,500p'echo'--- location of enumeration definitions ---'
rg -n -C 3 'void\s+enumerateLedmaps\s*\(|bool\s+requestJSONBufferLock\s*\(|void\s+releaseJSONBufferLock\s*\(' wled00 --glob '*.{cpp,h}'
Length of output: 24750
@DedeHai No. My two-request example requires an overlap, but not necessarily misbehaving software or an attack. For example, two users could save settings at nearly the same time. I have not established how likely that is.
There is also a possible single-request scenario on ESP32. When /json/cfg contains multiple bus entries, deserializeConfig() sets doInitBusses after each entry, before it finishes parsing the rest. The main loop could start initialization while the request is still adding entries. See cfg.cpp Lines 228–295.
The 9 ms in my earlier reply was a frame transmission estimate, not a measured request-spacing limit or race window. Neither scenario has been reproduced, so I cannot quantify its likelihood or say that normal use will trigger it.
Learnings used
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
Prefer compact function parameter lists and `if` conditions rather than putting each parameter or condition part on its own line. Wrap parameter lists only when they become very long.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
There should always be a space between a keyword and its condition and between the condition and brace.
Within the condition, no space should be between the parenthesis and variables.
Spaces between variables and operators are up to the authors discretion.
There should be no space between function names and their argument parenthesis.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Comments
There is no hard character limit for a comment within a line,
though as a rule of thumb consider wrapping after 120 characters.
Inline comments are OK if they describe that line only and are not exceedingly wide.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Comments
Comments should have a space between the delimiting characters (e.g. `//`) and the comment text.
We're gradually adopting this style - don't worry if you see older code without spaces!
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:24:49.630Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Source Code from an AI agent or bot
#### Best Practice with AI
- ✅ **Be transparent** - Add comments `// AI: below section was generated by an AI` ... `// AI: end` around larger chunks
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:24:49.630Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Blocks
Whether the opening bracket of e.g. an `if` block is in the same line as the condition or in a separate line is up to your discretion. If there is only one statement, leaving out block brackets is acceptable.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/index.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/iro.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/common.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Activity
[-]Investigate cross-task race in bus configuration handoff[/-][+]Investigate potential cross-task race in bus configuration handoff[/+]DedeHai commentedon Dec 3, 2026
@coderabbitai please provide a scenario where this can happen, including timing estimates.
coderabbitai commentedon Dec 3, 2026
Analysis chain
Script executed:
Length of output: 2763
Script executed:
Length of output: 32796
Script executed:
Length of output: 76743
Script executed:
Length of output: 27231
@DedeHaiHere is a possible ESP32 interleaving with two LED settings requests. The times are illustrative, not measurements.Assume an existing 300-pixel WS2812 RGB bus is transmitting when the first request completes. At 800 kbit/s, its 24 bits per pixel take about 9 ms to transmit, plus latch time.
busConfigsand setsdoInitBusses = true.WLED::loop()clears the flag and entersfinalizeInit(). AssumeremoveAll()must wait about 7 ms for the current frame.doInitBusses = true. This assumes the request finishes during the wait.busConfigs.finalizeInit()again. If the vector is still empty, that call removes the buses and constructs none.The relevant code is in
wled00/set.cppLine 291 and Line 470,wled00/wled.cppLine 239, andwled00/FX_fcn.cppLine 1332–1368.If request B instead appends during vector iteration, reallocation could invalidate the loop’s references. That requires a narrower overlap than the example above.
The 9 ms is a wire-time estimate, not a measured race window. The actual wait and request duration depend on the driver, frame phase, configuration, and scheduling. I have not reproduced this failure. To establish the window, timestamp the flag writes,
removeAll()wait, vector appends, iterations, and clear during repeated requests.Learnings used
You are interacting with an AI system.
DedeHai commentedon Dec 3, 2026
@coderabbitai so it requires external software to "misbehave" or a deliberate attack that sends configs within a few milliseconds?
coderabbitai commentedon Dec 3, 2026
Analysis chain
Script executed:
Length of output: 59375
Script executed:
Length of output: 24750
@DedeHaiNo. My two-request example requires an overlap, but not necessarily misbehaving software or an attack. For example, two users could save settings at nearly the same time. I have not established how likely that is.There is also a possible single-request scenario on ESP32. When
/json/cfgcontains multiple bus entries,deserializeConfig()setsdoInitBussesafter each entry, before it finishes parsing the rest. The main loop could start initialization while the request is still adding entries. Seecfg.cppLines 228–295.The 9 ms in my earlier reply was a frame transmission estimate, not a measured request-spacing limit or race window. Neither scenario has been reproduced, so I cannot quantify its likelihood or say that normal use will trigger it.
Learnings used
You are interacting with an AI system.