Strange multiprocessing bug

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
RcSepp
Posts: 1
Joined: Tue Sep 14, 2021 1:00 am

Strange multiprocessing bug

Post by RcSepp » Tue Sep 14, 2021 1:30 am

Hi,

This is my first post at this Forum. I've used Micropython for a few weeks now and it is awesome! Thanks for this great Python port!

Unfortunately I believe I stumbled onto a bug that causes my RP2 board to crash when using multiprocessing in combination with imports.

Test setup:
1. Connect a Raspberry Pi Pico with firmware image rp2-pico-20210902-v1.17.uf2 via USB.
2. Launch Thonny in MicroPython (Raspberry Pi Pico) mode.
3. Create an empty file and store it in Pico's root directory as "some_module.py"
4. Run the following code. -> The Pico will crash (usually in line

Code: Select all

for bar in foo.values()
after ~2 iterations).
5. Reset the Pico by unplugging and replugging the USB cable and pressing the STOP button (CTRL-F2).
6. Remove the line

Code: Select all

import some_module
.
7. Run the code again. It will now finish successfully.

Code: Select all

import time, _thread
import some_module

def some_thread():
	for i in range(10):
		print(i)
		time.sleep(0.5)

_thread.start_new_thread(some_thread, ())

foo = {}
while True:
	for bar in foo.values():
		pass
Additional notes:
* I'm not sure whether this is a board-specific or general problem, because I only have access to a Raspberry PI Pico.
* I tested the above on 2 different Pico's, so I don't think it's a hardware glitch.
* I tested a slightly modified version (with a blinking led) without Thonny (using rshell) and the Pico still crashed, so I don't think the problem comes from Thonny either.

Post Reply