micropython / micropython/micropython
segfault with improper use of super()
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 22.1k
- Forks
- 9k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 16
Description
Port, board and/or hardware
unix, coverage build
MicroPython version
MicroPython v1.26.0-preview.387.ge4e97f5aa7.dirty on 2025-07-20; linux [GCC 12.2.0] version
Reproduction
Run the following code:
import framebuf
class FB(framebuf.FrameBuffer):
def __init__(self, n):
self = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
fb = FB(n=3)
Expected behaviour
super() should not segfault.
Observed behaviour
crash in native_base_init_wrapper
Program received signal SIGSEGV, Segmentation fault.
0x00005555556120c7 in native_base_init_wrapper (n_args=5, args=0x7fffffffd6c0,
kw_args=0x7fffffffd510) at ../../py/objtype.c:91
91 instance_count_native_bases(self->base.type, &native_base);
(gdb) p self
$1 = (mp_obj_instance_t *) 0x7
Additional Information
This is a minimized version of a script produced by fuzzing micropython.
Code of Conduct
Yes, I agree
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example in a Unix coverage build, then inspect native_base_init_wrapper in ../../py/objtype.c around line 91, where the crash reports self as an invalid pointer. Verify the behavior after the issue is addressed by rerunning the example and confirming that improper use of super() no longer segfaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100