FuelLabs / fuel-vm

Fuel v2 interpreter in Rust
Other
358 stars 88 forks source link

Store stack and heap separately #697

Closed xgreenx closed 7 months ago

xgreenx commented 8 months ago

Closes https://github.com/FuelLabs/fuel-vm/issues/452

Spec PR: https://github.com/FuelLabs/fuel-specs/pull/566

Dentosal commented 7 months ago

There's a subtle bug in the implementation here: It's possible to extend the stack, then shrink the stack, and then extend the heap to be where the stack once was. Then reading from that memory area would read from the memory that was in the stack, and not from the heap that's on that region now. Fortunately we never shrink the heap, so just truncating the `stack´ field every time we grow heap over it fixes that.

Fixed in 10fed83b

Dentosal commented 7 months ago

Another breaking change: Allocating new heap space with ALOC now zeroes memory.