← index #18108Issue #17467
Related · medium · value 1.832
QUERY · ISSUE

mpy-cross viper incompatibility with OBJ_REPR_B

openby jepleropened 2025-09-20updated 2025-09-20
bug

Port, board and/or hardware

unix port, obj_repr_b, x86 (32-bit)

MicroPython version

based on v1.27.0-preview-154-g44986b1f04

Reproduction

  1. Make a 32-bit REPR_B "standard" or "coverage" build (from e.g., #17688)
  2. Run RUN_TESTS_MPY_CROSS_FLAGS="--mpy-cross-flags=\"-march=x86 -msmall-int-bits=30\"" make -C ports/unix/ VARIANT=standard test_full_no_native # or VARIANT=coverage, depending

Expected behaviour

Tests pass

Observed behaviour

12 tests failed: micropython/native_gen.py micropython/native_misc.py micropython/native_try.py micropython/viper_import.py micropython/native_try_deep.py micropython/native_while.py micropython/native_with.py micropython/viper_misc3.py micropython/native_closure.py micropython/native_const.py micropython/native_for.py micropython/viper_with.py

I didn't dig deeply because native & viper were not important to my use case but I think that there are some assumptions about the encoding of small integer values as discussed in a related PR: https://github.com/micropython/micropython/pull/17688#issuecomment-3075383706

        } else if (si->vtype == VTYPE_INT || si->vtype == VTYPE_UINT) {
            ASM_MOV_REG_IMM(emit->as, reg_dest, (uintptr_t)MP_OBJ_NEW_SMALL_INT(si->data.u_imm));

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

mpy-cross: Assertion failed for `-march=debug` and Viper code

closedby agattiopened 2025-06-09updated 2025-06-16
bugpy-core

Port, board and/or hardware

mpy-cross on Linux/amd64

MicroPython version

MicroPython v1.26.0-preview.196.g5f058e986 on 2025-06-09; linux [GCC 15.1.1] version

Reproduction

  1. Build mpy-cross without any special flags or parameters (as in, make -C mpy-cross clean && make -C mpy-cross
  2. Run ./mpy-cross/build/mpy-cross -march=debug ./tests/micropython/viper_ptr16_store.py

Expected behaviour

mpy-cross should not crash on exit but terminate gracefully.

Observed behaviour

mpy-cross will crash with:

mpy-cross: ../py/asmbase.c:56: mp_asm_base_start_pass: Assertion `as->code_base != NULL' failed.

after dumping native meta-opcodes to STDOUT.

Additional Information

This only happens for Viper code. For example, dumping tests/micropython/native_closure.py or tests/micropython/meminfo.py doesn't trigger the assertion.

I haven't really looked into this, but it seems like Viper code would still trigger an emit pass even for the debug arch? This could probably be fixed if N_DEBUG would be propagated into py/asmbase.c too but it doesn't seem to be the case.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied