Commit 0e2d67c
committed
extmod/zephyr_kernel: Use static thread pool to prevent GC heap corruption.
Thread structures allocated in the GC heap caused corruption during
concurrent gc.collect() operations. When thread A runs GC and scans
thread B's structure, the GC could relocate/compact thread B's structure
mid-scan, invalidating pointers and causing memory corruption.
Solution: Allocate all thread structures from a static pool outside the
GC heap. This matches the ports/zephyr pattern and ensures thread
structures remain stable during GC operations.
Changes:
- Add static thread_pool[MP_THREAD_POOL_SIZE] array
- Add thread_pool_alloc() and thread_pool_free() functions
- Replace m_new_obj() calls with static pool allocation
- Free threads back to pool in cleanup instead of GC reclamation
This fixes string/QSTR corruption with 2-3 concurrent threads calling
gc.collect(). Tests with 4+ threads still exhibit crashes indicating
additional issues remain to be investigated.
Signed-off-by: Andrew Leech <[email protected]>1 parent 4e29364 commit 0e2d67c
File tree
866 files changed
+13685
-26
lines changed- extmod/zephyr_kernel/kernel
- ports
- extmod/zephyr_kernel
- kernel
- lib/zephyr
- arch/arm/core
- cortex_m
- kernel
- lib
- os
- utils
- stm32/.ck
- boards
- ADAFRUIT_F405_EXPRESS
- ARDUINO_GIGA
- ARDUINO_NICLA_VISION
- ARDUINO_OPTA
- ARDUINO_PORTENTA_H7
- B_L072Z_LRWAN1
- B_L475E_IOT01A
- CERB40
- ESPRUINO_PICO
- GARATRONIC_NADHAT_F405
- GARATRONIC_PYBSTICK26_F411
- HYDRABUS
- LEGO_HUB_NO6
- LEGO_HUB_NO7
- LIMIFROG
- MIKROE_CLICKER2_STM32
- MIKROE_QUAIL
- NETDUINO_PLUS_2
- NUCLEO_F091RC
- NUCLEO_F401RE
- NUCLEO_F411RE
- NUCLEO_F412ZG
- NUCLEO_F413ZH
- NUCLEO_F429ZI
- NUCLEO_F439ZI
- NUCLEO_F446RE
- NUCLEO_F722ZE
- NUCLEO_F746ZG
- NUCLEO_F756ZG
- NUCLEO_F767ZI
- NUCLEO_G0B1RE
- NUCLEO_G474RE
- NUCLEO_H563ZI
- NUCLEO_H723ZG
- NUCLEO_H743ZI2
- NUCLEO_H743ZI
- NUCLEO_L073RZ
- NUCLEO_L152RE
- NUCLEO_L432KC
- NUCLEO_L452RE
- NUCLEO_L476RG
- NUCLEO_L4A6ZG
- NUCLEO_WB55
- NUCLEO_WL55
- OLIMEX_E407
- OLIMEX_H407
- PYBD_SF2
- PYBD_SF3
- PYBD_SF6
- PYBLITEV10
- PYBV10
- PYBV11
- PYBV3
- PYBV4
- SPARKFUN_MICROMOD_STM32
- STM32F411DISC
- STM32F429DISC
- STM32F439
- STM32F4DISC
- STM32F769DISC
- STM32F7DISC
- STM32H573I_DK
- STM32H7B3I_DK
- STM32L476DISC
- STM32L496GDISC
- USBDONGLE_WB55
- VCC_GND_F407VE
- VCC_GND_F407ZG
- VCC_GND_H743VI
- WEACT_F411_BLACKPILL
- common_isr_ram
- common_isr_rom
- lwip_inc
- arch
- mbedtls
- mboot
- usbdev
- class
- inc
- src
- core
- inc
- src
- usbhost
- Class
- AUDIO
- Inc
- Src
- CDC
- Inc
- Src
- HID
- Inc
- Src
- MSC
- Inc
- Src
- MTP
- Inc
- Src
- Template
- Inc
- Src
- Core
- Inc
- Src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
866 files changed
+13685
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
176 | 205 | | |
177 | 206 | | |
178 | 207 | | |
| |||
195 | 224 | | |
196 | 225 | | |
197 | 226 | | |
198 | | - | |
199 | 227 | | |
200 | 228 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
205 | 235 | | |
206 | 236 | | |
207 | 237 | | |
| |||
290 | 320 | | |
291 | 321 | | |
292 | 322 | | |
293 | | - | |
| 323 | + | |
| 324 | + | |
294 | 325 | | |
295 | 326 | | |
296 | 327 | | |
| |||
331 | 362 | | |
332 | 363 | | |
333 | 364 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 365 | + | |
338 | 366 | | |
339 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
340 | 372 | | |
341 | 373 | | |
342 | 374 | | |
343 | 375 | | |
344 | 376 | | |
345 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
346 | 383 | | |
347 | | - | |
348 | | - | |
349 | 384 | | |
350 | 385 | | |
351 | 386 | | |
352 | 387 | | |
353 | 388 | | |
354 | | - | |
355 | | - | |
356 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
357 | 392 | | |
358 | 393 | | |
359 | 394 | | |
360 | 395 | | |
361 | | - | |
362 | | - | |
363 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
364 | 399 | | |
365 | 400 | | |
366 | 401 | | |
367 | | - | |
| 402 | + | |
| 403 | + | |
368 | 404 | | |
369 | 405 | | |
370 | 406 | | |
| |||
431 | 467 | | |
432 | 468 | | |
433 | 469 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
440 | 480 | | |
441 | 481 | | |
442 | 482 | | |
| |||
0 commit comments