Commit Graph
24398 Commits
Author SHA1 Message Date
J. Nick Koston 4d1e1645dc Merge branch 'fix-rp2040-tcp-race' into integration 2026-03-10 01:08:22 -10:00
J. Nick Koston 81d12fd14a [socket] Hold lwip lock for entire write() operation
Same pattern as writev — write() calls internal_write_() then
internal_output_(), each acquiring the lock separately. Hold
the lock at the outer scope so inner calls just bump the
recursion counter.
2026-03-10 00:57:36 -10:00
J. Nick Koston cc05bf3ed2 [socket] Add LWIP_LOCK to socket factory functions
tcp_new() is an lwip core API call that must be bracketed with
the lwip lock on RP2040 per pico-sdk docs. Add LWIP_LOCK() to
socket() and socket_listen() factory functions.
2026-03-10 00:55:34 -10:00
J. Nick Koston c182c0c74f [socket] Hold lwip lock for entire readv/writev scatter-gather operation
Avoid repeated lock acquire/release cycles per iovec element.
The recursive mutex re-entry in inner calls is nearly free (counter
bump), while the outer lock prevents the expensive IRQ disable/enable
on each iteration.
2026-03-10 00:53:01 -10:00
J. Nick Koston a88e9b8146 [socket] Fix RP2040 TCP race condition between lwip callbacks and main loop
On RP2040 (Pico W), arduino-pico sets PICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1,
which means lwip callbacks (recv_fn, accept_fn, err_fn) run from a PendSV
interrupt — not the main loop. This allows them to preempt read(), write(),
close(), and accept() at any point, causing race conditions on shared state
like the rx_buf_ pbuf chain.

The most critical race: recv_fn calls pbuf_cat(rx_buf_, pb) while read() is
freeing nodes in the same chain, leading to use-after-free and lwip's
"Creating an infinite loop" assertion panic. This is the root cause of #10681.

Fix: implement RP2040's LwIPLock (previously a no-op) to call
cyw43_arch_lwip_begin/end, which acquires the pico-sdk async_context recursive
mutex. Add LWIP_LOCK() guards to all main-loop lwip API call sites in the
socket layer.

On ESP8266, lwip callbacks run cooperatively from the main loop, so
LwIPLock remains a no-op.

Closes #10681
2026-03-10 00:34:20 -10:00
J. Nick Koston 4b50d14496 [serial_proxy] Reduce loop() overhead by disabling when idle and splitting read path (#14673) 2026-03-10 02:10:03 -05:00
J. Nick Koston 1202f54a75 Merge branch 'serial-proxy-loop-stack-optimization' into integration 2026-03-09 20:49:48 -10:00
J. Nick Koston 5d6301d312 missing guard 2026-03-09 20:42:41 -10:00
J. Nick Koston cd6ef8e41d [serial_proxy] Reduce loop() stack usage by splitting read path
Split the 256-byte UART read buffer into a separate noinline
read_and_send_() helper so the common "no data" path in loop()
only needs a 32-byte stack frame instead of 288 bytes.

Also reorder checks so api_connection_ == nullptr bails out
first, avoiding the more expensive disconnect detection when
no client is subscribed.
2026-03-09 20:34:45 -10:00
J. Nick Koston bc6691da9a Merge remote-tracking branch 'origin/rp2040-upload-improvements' into integration 2026-03-09 17:49:47 -10:00
J. Nick Koston 4b83de10e5 make linux error reporting more helpful 2026-03-09 17:45:03 -10:00
J. Nick Koston 399d695a39 Merge remote-tracking branch 'upstream/dev' into rp2040-upload-improvements 2026-03-09 17:45:00 -10:00
e82f0f4432 [cpptests] support testing platform components (#13075)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-10 02:41:02 +00:00
00f809f5f0 [sen6x] fix memory leak issue (#14623)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-09 21:45:20 -04:00
c31ac662bd [multiple] Fix crashes from malformed external input (#14643)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-09 20:39:58 -04:00
J. Nick Koston d6ce5dda81 [ci] Skip YAML anchor keys in integration fixture component extraction (#14670) 2026-03-09 22:54:56 +00:00
J. Nick Koston dadbdd0f7b [ci] Make codeowner label update non-fatal for fork PRs (#14668) 2026-03-09 12:34:31 -10:00
d96be88ff5 [multiple] Fix reliability issues in 5 components (#14655)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-09 18:32:57 -04:00
Jonathan SwobodaandClaude Opus 4.6 d2686b49be [canbus] Fix multiple MCP component bugs (#14461)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 18:15:33 -04:00
Keith Burzinski 468ce74c8e [api][serial_proxy] Fix dangling pointer (#14640) 2026-03-09 17:04:47 -05:00
Jonathan SwobodaandClaude Opus 4.6 b3fc43c13c [multiple] Fix wrong behavior in sensor calculations and drivers (#14644)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 18:00:17 -04:00
Jonathan SwobodaandClaude Opus 4.6 308e8e78cd [ble_scanner] Escape special characters in JSON output (#14664)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:59:36 -04:00
Jonathan SwobodaandClaude Opus 4.6 470d9160a5 [demo] Fix alarm control panel auth bypass when code is omitted (#14645)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:57:02 -04:00
Jonathan SwobodaandClaude Opus 4.6 9902447834 [multiple] Fix minor bugs in 8 components (#14650)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:51:50 -04:00
Jonathan SwobodaandClaude Opus 4.6 7c1b9f0cb4 [multiple] Fix wrong behavior in 5 components (#14647)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:22:06 -04:00
Jonathan SwobodaandClaude Opus 4.6 fecedeb018 [multiple] Fix crashes from malformed external input (batch 2) (#14651)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:20:09 -04:00
Jonathan SwobodaandClaude Opus 4.6 9418f35cc3 [multiple] Remove unnecessary heap allocations in 4 components (#14656)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:18:44 -04:00
Jonathan SwobodaandClaude Opus 4.6 08a0608a48 [wifi][captive_portal][heatpumpir][es8388] Fix wrong behavior in 4 components (#14657)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:18:21 -04:00
Jonathan SwobodaandClaude Opus 4.6 b721cd48e5 [hmc5883l][mmc5603][honeywellabp2][xgzp68xx][max9611] Fix uninitialized members (#14659)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:18:07 -04:00
Jonathan SwobodaandClaude Opus 4.6 75f55adbfa [api][at581x][vl53l0x] Fix bounds check issues in 3 components (#14660)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:17:31 -04:00
Jonathan SwobodaandClaude Opus 4.6 a379e5a635 [runtime_image][st7701s] Fix BMP decoder and LCD init bugs (#14663)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:16:29 -04:00
dependabot[bot] 019db74582 Bump setuptools from 82.0.0 to 82.0.1 (#14665)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-09 20:44:27 +00:00
Jonathan SwobodaandClaude Opus 4.6 31f4b4d00d [multiple] Fix undefined behavior across components (#14639)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:33:08 -04:00
J. Nick Koston 1b4de89d02 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-08 22:08:11 -10:00
J. Nick Koston 7ac8b790fc Remove redundant rx_buf_ size checks before resize
APIBuffer::resize() is already just a capacity check + store,
making the outer size-equality guard redundant. Saves ~8 bytes
of code size across both frame helpers.
2026-03-08 22:07:23 -10:00
J. Nick Koston 6f89428333 Merge branch 'inline-varint-parse-fast-path' into integration 2026-03-08 21:06:43 -10:00
J. Nick KostonandClaude Opus 4.6 765bb3298e [api] Use PROTO_VARINT_PARSE_FAILED constant in parse failure returns
Replace magic {0, 0} with {0, PROTO_VARINT_PARSE_FAILED} in parse_slow()
and parse_wide() for consistency with the named sentinel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:06:22 -10:00
J. Nick KostonandClaude Opus 4.6 e7ce2703e8 [api] Add explicit static_cast<uint32_t> in decode_zigzag32 calls
On BLE builds where proto_varint_value_t is uint64_t, decode_zigzag32()
takes uint32_t — make the narrowing explicit to match the static_cast
pattern used for other type conversions in generated code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:05:07 -10:00
J. Nick KostonandClaude Opus 4.6 972d0978bd [api] Add explicit static_cast<uint32_t> in decode_zigzag32 calls
On BLE builds where proto_varint_value_t is uint64_t, decode_zigzag32()
takes uint32_t — make the narrowing explicit to match the static_cast
pattern used for other type conversions in generated code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:04:55 -10:00
J. Nick Koston 6a0539b3d6 Merge branch 'inline-varint-parse-fast-path' into integration 2026-03-08 21:00:55 -10:00
J. Nick KostonandClaude Opus 4.6 5dbf35051a [api] Add explicit static_cast<uint32_t> for tag/field_length narrowing
Consistency with frame helper code — makes the uint64→uint32 narrowing
explicit on BLE builds where proto_varint_value_t is uint64_t.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:58:13 -10:00
J. Nick KostonandClaude Opus 4.6 9f57c2a9b6 [api] Fix HELPER_LOG format mismatch and remove unused is_varint64 codegen field
- Cast msg_size/type_varint.value to uint32_t in HELPER_LOG to match PRIu32
  format (proto_varint_value_t is uint64_t on BLE builds)
- Remove unused is_varint64 field from api_protobuf.py TypeInfo classes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:52:26 -10:00
J. Nick KostonandClaude Opus 4.6 ce70c955c4 [api] Remove as_uint16/as_uint32 accessors from ProtoVarIntResult, use .value directly
Address code review feedback:
- Remove as_uint16() and as_uint32() accessors from ProtoVarIntResult
- Use .value directly with static_cast where narrowing is needed
- Fix ESP_LOGV truncation: use PRIu64 with static_cast<uint64_t> for BLE builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 19:52:03 -10:00
J. Nick Koston fab59c86a7 Merge remote-tracking branch 'upstream/dev' into inline-varint-parse-fast-path 2026-03-08 19:07:58 -10:00
J. Nick KostonandClaude Opus 4.6 a9ad0cc3f3 [api] Remove unused ProtoVarInt instance members and ProtoVarIntResult accessors
After moving decode_varint to raw proto_varint_value_t, the type-
conversion accessors (as_bool, as_int32, as_sint32, as_uint64, etc.)
on ProtoVarIntResult are dead code. ProtoVarInt itself is now only
used as a static method container for parse(), so remove its
constructors, instance accessors, and value_ member.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:58:54 -10:00
J. Nick KostonandClaude Opus 4.6 b838085e41 [api] Use proto_varint_value_t type alias instead of #ifdef blocks
Replace per-override #ifdef USE_API_VARINT64 conditionals with a
single type alias proto_varint_value_t, eliminating preprocessor
blocks from every decode_varint signature in api_pb2.cpp/h.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:56:15 -10:00
J. Nick KostonandClaude Opus 4.6 fcd72336f0 [api] Change decode_varint parameter from ProtoVarIntResult to raw value type
Pass uint32_t (or uint64_t when USE_API_VARINT64 is defined) directly
to decode_varint() instead of the ProtoVarIntResult struct. This
eliminates accessor method overhead in each of the 51 overrides,
replacing value.as_uint32() with direct value usage, value.as_bool()
with value != 0, etc. No vtable growth - single virtual method with
conditionally-typed parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:39:59 -10:00
J. Nick KostonandClaude Opus 4.6 f4724d7797 Split parse() into parse() and parse_non_empty()
parse_non_empty() has no len==0 check (with debug assert) for callers
that guarantee len >= 1 (e.g. after while (ptr < end)).

parse() adds the len==0 guard and delegates to parse_non_empty() for
callers where the buffer may be empty (e.g. value parse after tag
advance in decode(), frame helper header parsing).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:18:19 -10:00
0db9137d91 [multiple] Add division by zero guards (#14634)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
2026-03-09 00:10:48 -04:00
Clyde Stubbs f3ca86b670 [ci-custom] Directions on constant hoisting (#14637) 2026-03-08 23:48:03 -04:00