Skip to content

Color dictionary gets GCed #314

@dlech

Description

@dlech

Might have found something useful... 💡

I'm wondering if we've got a more generic memory corruption issue with stdin, which just happens to manifest itself as a lockup on Technic Hub. The following apparent memory corruption occurs on both Technic Hub and Prime Hub.

Neither hub freezes, so if this is the same issue, debugging should be easier. (Assuming it's not just a bad implementation of the color type).

EDIT: This is probably just the Color dict being garbage-collected, which is a separate issue. But it did lead to some additional insights with the freeze possibly coinciding with garbage collection. See posts below.

from pybricks.parameters import Color

from usys import stdin
from uselect import poll

p = poll()
p.register(stdin)

# Prints the whole color dictionary (good)
print(Color)

# Wait for one key press
while not p.poll(0):
    pass

# Prints an empty dictionary (bad)
print(Color)

Originally posted by @laurensvalk in #306 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions