Python output causes segfault

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
srmppd
Posts: 2
Joined: Mon May 11, 2020 1:13 pm

Python output causes segfault

Post by srmppd » Mon May 11, 2020 1:50 pm

I'm creating my own port and now have the following problem:
When I execute a frozen MPY using pyexec_frozen_module() it runs fine as long as the module does not create any output. But as soon as there is a print() or a raise in the python code I get something like the following output followed by an immediate segfault:

Code: Select all

Traceback (most recent call last):
  File "q", line 1448734720
I looked at the backtrace and the function in which the segfault happens is qstr_data() which is called by mp_obj_print_exception() via mp_vprintf() and mp_printf(). What seems strange to me is that qstr_data() is called with the parameter q=377. I had a look at my qstrdefs.generated.h and it contains 377 elements, so I guess this is where the problem lies but I don't have a clue where to look next to debug this and I hope someone has an idea.

srmppd
Posts: 2
Joined: Mon May 11, 2020 1:13 pm

Re: Python output causes segfault

Post by srmppd » Fri May 15, 2020 9:32 pm

Adding

Code: Select all

#define MICROPY_QSTR_EXTRA_POOL (mp_qstr_frozen_const_pool)
to my mpconfigport.h seems to have solved my problem.

Post Reply