pw_containers: Fix IntrusiveList::Item move assignment test

This CL revisits the move assignment operator added to
`intrusive_list_impl::List::Item`. This operator allows storing the
backing items, which are not owned in a list, in a `Vector` that can be
moved.

The test for this assignment operator exposed a latent bug in
`pw::Vector`'s destructor. The call to `clear` in the base vector
class occurs after the derived vector's destructor has invalidated the
items' memory. Thus, if an element references its own memory in its
destructor, as `IntrusiveList::Item`s do, then letting a vector with
elements fall out of scope will trigger a use-after-dtor MSAN bug.

This vector bug is tracked by b/313899658. Several tests are added that test move operators with `std::array`s instead of `Vector`s. A `Vector` test is retained, since that use case is needed for FuzzTest. It has been updated to explicitly clear the vector.

Bug: b/303634979

Change-Id: I132756dc25e4d14f8e8e30868f13f3208a260b38
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/182951
Reviewed-by: Taylor Cramer <cramertj@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Aaron Green <aarongreen@google.com>
4 files changed
tree: a6c31d32d3100234d278e26aeab6405f533e7ddc
  1. .allstar/
  2. .vscode/
  3. build_overrides/
  4. docker/
  5. docs/
  6. kudzu/
  7. pw_alignment/
  8. pw_allocator/
  9. pw_analog/
  10. pw_android_toolchain/
  11. pw_arduino_build/
  12. pw_assert/
  13. pw_assert_basic/
  14. pw_assert_log/
  15. pw_assert_tokenized/
  16. pw_assert_zephyr/
  17. pw_async/
  18. pw_async_basic/
  19. pw_base64/
  20. pw_bloat/
  21. pw_blob_store/
  22. pw_bluetooth/
  23. pw_bluetooth_hci/
  24. pw_bluetooth_profiles/
  25. pw_bluetooth_sapphire/
  26. pw_boot/
  27. pw_boot_cortex_m/
  28. pw_build/
  29. pw_build_info/
  30. pw_build_mcuxpresso/
  31. pw_bytes/
  32. pw_checksum/
  33. pw_chre/
  34. pw_chrono/
  35. pw_chrono_embos/
  36. pw_chrono_freertos/
  37. pw_chrono_rp2040/
  38. pw_chrono_stl/
  39. pw_chrono_threadx/
  40. pw_chrono_zephyr/
  41. pw_cli/
  42. pw_compilation_testing/
  43. pw_console/
  44. pw_containers/
  45. pw_cpu_exception/
  46. pw_cpu_exception_cortex_m/
  47. pw_crypto/
  48. pw_digital_io/
  49. pw_digital_io_mcuxpresso/
  50. pw_digital_io_rp2040/
  51. pw_docgen/
  52. pw_doctor/
  53. pw_emu/
  54. pw_env_setup/
  55. pw_file/
  56. pw_format/
  57. pw_function/
  58. pw_fuzzer/
  59. pw_hdlc/
  60. pw_hex_dump/
  61. pw_i2c/
  62. pw_i2c_linux/
  63. pw_i2c_mcuxpresso/
  64. pw_ide/
  65. pw_interrupt/
  66. pw_interrupt_cortex_m/
  67. pw_interrupt_xtensa/
  68. pw_interrupt_zephyr/
  69. pw_intrusive_ptr/
  70. pw_kvs/
  71. pw_libc/
  72. pw_libcxx/
  73. pw_log/
  74. pw_log_android/
  75. pw_log_basic/
  76. pw_log_null/
  77. pw_log_rpc/
  78. pw_log_string/
  79. pw_log_tokenized/
  80. pw_log_zephyr/
  81. pw_malloc/
  82. pw_malloc_freelist/
  83. pw_metric/
  84. pw_minimal_cpp_stdlib/
  85. pw_module/
  86. pw_multibuf/
  87. pw_multisink/
  88. pw_package/
  89. pw_perf_test/
  90. pw_persistent_ram/
  91. pw_polyfill/
  92. pw_preprocessor/
  93. pw_presubmit/
  94. pw_protobuf/
  95. pw_protobuf_compiler/
  96. pw_random/
  97. pw_result/
  98. pw_ring_buffer/
  99. pw_router/
  100. pw_rpc/
  101. pw_rpc_transport/
  102. pw_rust/
  103. pw_snapshot/
  104. pw_software_update/
  105. pw_span/
  106. pw_spi/
  107. pw_spi_mcuxpresso/
  108. pw_status/
  109. pw_stm32cube_build/
  110. pw_stream/
  111. pw_stream_shmem_mcuxpresso/
  112. pw_stream_uart_linux/
  113. pw_stream_uart_mcuxpresso/
  114. pw_string/
  115. pw_symbolizer/
  116. pw_sync/
  117. pw_sync_baremetal/
  118. pw_sync_embos/
  119. pw_sync_freertos/
  120. pw_sync_stl/
  121. pw_sync_threadx/
  122. pw_sync_zephyr/
  123. pw_sys_io/
  124. pw_sys_io_ambiq_sdk/
  125. pw_sys_io_arduino/
  126. pw_sys_io_baremetal_lm3s6965evb/
  127. pw_sys_io_baremetal_stm32f429/
  128. pw_sys_io_emcraft_sf2/
  129. pw_sys_io_mcuxpresso/
  130. pw_sys_io_rp2040/
  131. pw_sys_io_stdio/
  132. pw_sys_io_stm32cube/
  133. pw_sys_io_zephyr/
  134. pw_system/
  135. pw_target_runner/
  136. pw_thread/
  137. pw_thread_embos/
  138. pw_thread_freertos/
  139. pw_thread_stl/
  140. pw_thread_threadx/
  141. pw_thread_zephyr/
  142. pw_tls_client/
  143. pw_tls_client_boringssl/
  144. pw_tls_client_mbedtls/
  145. pw_tokenizer/
  146. pw_tool/
  147. pw_toolchain/
  148. pw_toolchain_bazel/
  149. pw_trace/
  150. pw_trace_tokenized/
  151. pw_transfer/
  152. pw_unit_test/
  153. pw_unit_test_zephyr/
  154. pw_varint/
  155. pw_watch/
  156. pw_web/
  157. pw_work_queue/
  158. seed/
  159. targets/
  160. third_party/
  161. ts/
  162. zephyr/
  163. .bazelignore
  164. .bazelrc
  165. .black.toml
  166. .clang-format
  167. .clang-tidy
  168. .eslintrc.cjs
  169. .git-blame-ignore-revs
  170. .gitattributes
  171. .gitignore
  172. .gn
  173. .mypy.ini
  174. .prettierignore
  175. .prettierrc.cjs
  176. .pw_ide.yaml
  177. .pylintrc
  178. activate.bat
  179. Android.bp
  180. AUTHORS
  181. bootstrap.bat
  182. bootstrap.sh
  183. BUILD.bazel
  184. BUILD.gn
  185. BUILDCONFIG.gn
  186. CMakeLists.txt
  187. jest.config.ts
  188. Kconfig.zephyr
  189. LICENSE
  190. modules.gni
  191. OWNERS
  192. package-lock.json
  193. package.json
  194. pigweed.json
  195. PIGWEED_MODULES
  196. README.md
  197. rollup.config.js
  198. tsconfig.json
  199. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links