Log In  
Follow
erikharrison

Cart #mowuhefagi-0 | 2024-10-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

This cart shows what I think is a bug with the garbage collector interacting with weakrefs. Nothing should be drawn, yet sprite zero is shown. I'm not entirely sure how to show code here? I'm new!

Here are the steps:

Create a table with weakref values.
Add a value to that table.
Pass that table to a function.
The function uses a LOCAL variable to iterate over ALL() values of the table.
Return

The LOCAL variable holds a reference to the last member of the table. The LOCAL variable doesn't appear to get correctly garbage collected, and so neither does the last table member.

Weirdly, if I run stat(0) inside the function with the iterator, all is well. If I run it outside the function, nothing works.

1
2 comments