Skip to content

Fix RGB colors #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: fomu
Choose a base branch
from
Open

Fix RGB colors #1

wants to merge 1 commit into from

Conversation

0x0ece
Copy link

@0x0ece 0x0ece commented Jun 23, 2019

No description provided.

xobs pushed a commit that referenced this pull request Mar 24, 2020
xobs pushed a commit that referenced this pull request Mar 24, 2020
Removed robohatmm1_m0 from build.
xobs pushed a commit that referenced this pull request Mar 24, 2020
stm32 explicitily enable/disable vbus sense, fix warning
xobs pushed a commit that referenced this pull request Mar 24, 2020
xobs pushed a commit that referenced this pull request Mar 24, 2020
update to adafruit master
xobs pushed a commit that referenced this pull request Mar 24, 2020
xobs pushed a commit that referenced this pull request May 15, 2020
xobs pushed a commit that referenced this pull request May 15, 2020
xobs pushed a commit that referenced this pull request May 19, 2020
xobs added a commit that referenced this pull request Dec 24, 2020
Merge and a few final tweaks
xobs pushed a commit that referenced this pull request Dec 24, 2020
xobs pushed a commit that referenced this pull request Dec 24, 2020
A crash like the following occurs in the unix port:
```
Program received signal SIGSEGV, Segmentation fault.
0x00005555555a2d7a in mp_obj_module_set_globals (self_in=0x55555562c860 <ulab_user_cmodule>, globals=0x55555562c840 <mp_module_ulab_globals>) at ../../py/objmodule.c:145
145	    self->globals = globals;
(gdb) up
#1  0x00005555555b2781 in mp_builtin___import__ (n_args=5, args=0x7fffffffdbb0) at ../../py/builtinimport.c:496
496	                mp_obj_module_set_globals(outer_module_obj,
(gdb)
micropython#2  0x00005555555940c9 in mp_import_name (name=824, fromlist=0x555555621f10 <mp_const_none_obj>, level=0x1) at ../../py/runtime.c:1392
1392	    return mp_builtin___import__(5, args);
```

I don't understand how it doesn't happen on the embedded ports, because
the module object should reside in ROM and the assignment of self->globals
should trigger a Hard Fault.

By checking VERIFY_PTR, we know that the pointed-to data is on the heap
so we can do things like mutate it.
xobs pushed a commit that referenced this pull request Dec 24, 2020
xobs pushed a commit that referenced this pull request Dec 24, 2020
It was incorrect to NULL out the pointer to our heap allocated buffer in
`reset`, because subsequent to framebuffer_reset, but while
the heap was still active, we could call `get_bufinfo` again,
leading to a fresh allocation on the heap that is about to be destroyed.

Typical stack trace:
```
#1  0x0006c368 in sharpdisplay_framebuffer_get_bufinfo
micropython#2  0x0006ad6e in _refresh_display
micropython#3  0x0006b168 in framebufferio_framebufferdisplay_background
micropython#4  0x00069d22 in displayio_background
micropython#5  0x00045496 in supervisor_background_tasks
micropython#6  0x000446e8 in background_callback_run_all
micropython#7  0x00045546 in supervisor_run_background_tasks_if_tick
micropython#8  0x0005b042 in common_hal_neopixel_write
micropython#9  0x00044c4c in clear_temp_status
micropython#10 0x000497de in spi_flash_flush_keep_cache
micropython#11 0x00049a66 in supervisor_external_flash_flush
micropython#12 0x00044b22 in supervisor_flash_flush
micropython#13 0x0004490e in filesystem_flush
micropython#14 0x00043e18 in cleanup_after_vm
micropython#15 0x0004414c in run_repl
micropython#16 0x000441ce in main
```
When this happened -- which was inconsistent -- the display would keep
some heap allocation across reset which is exactly what we need to avoid.

NULLing the pointer in reconstruct follows what RGBMatrix does, and that
code is a bit more battle-tested anyway.

If I had a motivation for structuring the SharpMemory code differently,
I can no longer recall it.

Testing performed: Ran my complicated calculator program over multiple
iterations without observing signs of heap corruption.

Closes: micropython#3473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant