QUERY · ISSUE
Viper: ptr8(0)[0] = 1 causes SIGSEGV on unix port
bugproposed-close
Port, board and/or hardware
Unix
MicroPython version
MicroPython v1.27.0-preview.107.gd1607598f on 2025-09-09; linux [GCC 14.2.0] version
Reproduction
try:
import micropython
except ImportError:
print("SKIP missing micropython")
else:
try:
@micropython.viper
def poke0():
p = ptr8(0)
p[0] = 1
try:
poke0()
print("should not reach here")
except Exception as e:
print("EXC", type(e).__name__)
except AttributeError:
print("SKIP viper_not_available")
Expected behaviour
it would be helpful if either:
- Viper rejected obviously invalid addresses like 0 (and perhaps addr + size overflow) with a Python exception in a debug/safe build mode, or
- The docs explicitly call out that such code will crash the process.
Observed behaviour
The process crashes with SIGSEGV at the generated Viper instruction
[#0] 0x7ffff7fba051 → mov BYTE PTR [rbx], dl
[#1] 0x7ffff7e27f40 → rex.WX sbb rax, QWORD PTR [rax]
[#2] 0x5555555f39e4 → mp_cstack_usage()
[#3] 0x7ffff7e27b60 → rcr ch, 1
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
CANDIDATE · ISSUE
Large Viper code causing hang/crash on RP2350 but OK on RP2040
bug
Port, board and/or hardware
MicroPython v1.26.0 on 2025-08-09; Raspberry Pi Pico2 with RP2350
MicroPython version
MicroPython v1.26.0 on 2025-08-09; Raspberry Pi Pico2 with RP2350
Large viper functions have been improved in v26 and shown to work on RP2040. The same code on a RP2350 however causes the pico VM to hang or crash.
In the code below a DEPTH of 500 works but 600 crashes.
Reproduction
DEPTH = const(600)
src = "@micropython.viper\ndef big_jump() -> int:\n"
src += " x = 0\n"
src += " while x < 10:\n"
for i in range(DEPTH):
src += f" x += 1\n"
src += " return x"
#print(src)
exec(src)
print(big_jump())
### Expected behaviour
_No response_
### Observed behaviour
Observed behaviour is that the RP2350 is non responsive and requires a hard reset.
### Additional Information
No, I've provided everything above.
### Code of Conduct
Yes, I agree