fuzzball-muck / fuzzball

Ongoing development of the Fuzzball MUCK server software and associated functionality.
Other
47 stars 27 forks source link

(C) stack overflow from array_compare and nested arrays and array_pin #200

Open charlesreiss opened 6 years ago

charlesreiss commented 6 years ago

The MUF program

: main 
    { 1 2 3 }list ARRAY_PIN var! x
    { 4 5 6 }list ARRAY_PIN var! y
    x @ y @ 0 ARRAY_SETITEM POP
    y @ x @ 0 ARRAY_SETITEM POP
    x @ y @ ARRAY_COMPARE
;

causes the server to overflow its stack.

wyld-sw commented 6 years ago

Did we want to implement reference counting as part of the solution to this issue? If that's the approach, does anyone want to start implementing it?

charlesreiss commented 6 years ago

I'm not sure what you mean by reference counting.

With respect to deallocating arrays we already do reference counting...

A fix would be for the array compare functions to track the list of addresses visited so far on each "side" of the array compare and do something special (probably produce an error) when they detected a cycle.

This isn't quite just counting the number of times each array is reached during the compare because I think we want, e.g.

   { "repeated" }list array_pin var! x
   { x @ x @ }list { x @ x @ }list array_compare

to work.

wyld-sw commented 6 years ago

You're right; my fault. I misinterpreted something you said on FM.