Skip to content

Only make objects long lived if they are on the GC heap #2317

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

Merged

Conversation

babygrimes
Copy link

When using frozen bytecode compiled into the "firmware" (obviously not quite true in the Unix port), and said frozen bytecode has mp_type_bytes object(s) defined, and said object(s) are used as default arguments to functions generated SIGSEGV. After researching, I found this is due to the behavior of making certain things "long_lived". My specific failure occurred in make_str_long_lived, specifically trying to assign str->data, but in my case, "str" is a "ROM" pointer. In other words it is not a heap address, so the concept of making that long lived doesn't seem to apply.

This fix uses VERIFY_PTR (moved from gc.c to gc.h) to check the argument passed to make_obj_long_lived and do nothing if the pointer is not verified as a GC heap block pointer.

I don't have a debugging capability on my actual microcontrollers, but in concept this patch seems safe since the concept of a "long live" GC pointer doesn't seem to apply if the pointer can't be verified to begin with.

@babygrimes babygrimes changed the title * only make objects long lived if they are on the GC heap Only make objects long lived if they are on the GC heap Nov 22, 2019
@dhalbert dhalbert requested a review from tannewt November 23, 2019 20:56
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! Thank you for finding and fixing this issue!

@tannewt tannewt merged commit 6e3b363 into adafruit:master Nov 25, 2019
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.

3 participants