Double buffer heap corruption

Description

If I use a double buffer, then when soft resetting I get a heap corruption error.

What MCU/Processor/Board and compiler are you using?

ESP32+microPython bindings.

What do you experience?

If I declare my ili9341 display using the double buffer feature, and later try a soft reboot (ctrl-D from a REPL), I get a CORRUPT HEAP error leading to a hard reset.

What do you expect?

A normal soft reboot

Code to reproduce

A minimal example (file lvDsp.py):

import lvgl as lv
from ili9341 import ili9341
# M5Stack screen
disp = ili9341(miso=19, mosi=23, clk=18, cs=14, dc=27, rst=33, backlight=32,power=-1,power_on=-1, backlight_on=1,
        mhz=40, factor=4, hybrid=True, width=320, height=240,
        colormode=ili9341.COLOR_MODE_BGR, rot=ili9341.MADCTL_ML, invert=False, double_buffer=True)

print("Script end")

And a transcript from REPL:

>>> import lvDsp
ILI9341 initialization completed
Enable backlight
Double buffer
Script end
>>> 
──────────────────────────────────────────────────────────────────────────────────────────

Deinitializing ILI9341..
CORRUPT HEAP: multi_heap.c:477 detected at 0x3ffe4368
abort() was called at PC 0x4009a357 on core 1

ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000

Backtrace: 0x4009ad44:0x3ffdb6f0 0x4009b15d:0x3ffdb710 0x4009a357:0x3ffdb730 0x4009a788:0x3ffdb750 0x40086031:0x3ffdb770 0x4015225f:0x3ffdb790 0x40152dda:0x3ffdb7b0 0x400dfe11:0x3ffdb7d0 0x400dff4a:0x3ffdb7f0 0x400ee3a9:0x3ffdb810 0x400e412c:0x3ffdb8b0 0x400dfe11:0x3ffdb910 0x400e264e:0x3ffdb930 0x400e266d:0x3ffdb970 0x400dfe11:0x3ffdb990 0x400dfe3a:0x3ffdb9b0 0x4014ff75:0x3ffdb9d0 0x400e3f92:0x3ffdb9f0 0x400dfe11:0x3ffdba10 0x400dff05:0x3ffdba30 0x400e0b8c:0x3ffdba60 0x400d2e50:0x3ffdbae0 0x400d2ef8:0x3ffdbb30 0x400f7849:0x3ffdbb50 0x40090e99:0x3ffdbb80

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee

Etc. The continuous line being the indicator I typed ctrl-D for a soft reset.

Way to prevent the problem from occuring

Replace the double_buffer=True by a double_buffer=False in the creation of the display object.

I believe this is a known issue: https://github.com/littlevgl/lvgl/issues/1316#issuecomment-568212661

My bad, I had not seen the issue :blush: . I tend not to look into closed issues :nerd_face:

No problem. I just wanted to link to it so that we don’t end up with too many duplicate posts of the same bug.