monome / crow

Crow speaks and listens and remembers bits of text. A scriptable USB-CV-II machine
GNU General Public License v3.0
166 stars 34 forks source link

fix bug where aliasing an ii address before use could stack overflow #374

Closed trentgill closed 3 years ago

trentgill commented 3 years ago

Putting this here as I was staring at the code for an hour last night and think this could solve the problem in #341

Testing looks something like:

s = ii.wsyn
for i=1,100 do
  print(i, collectgarbage'count')
  s.ramp(0)
end

Without this fix, the RAM should be exhausted within a few iterations. This fix should allow substantially more without crashing (and perhaps won't crash at all). I'm reasonably sure the above will crash on the current main but that should be tested too.

Super happy for anyone else to confirm this.

Fixes #341

trentgill commented 3 years ago

tested & fixed.

works well even after 100 iterations only creates ~10kB of garbage (whereas before it would cause a hard-fault out-of-memory in 23 iterations).