lisdude / toaststunt

A network accessible, multi-user, programmable, interactive system for the creation of LambdaMOO style MOOs / MUDs.
63 stars 27 forks source link

recycle_waifs fix #5

Closed sorressean closed 5 years ago

sorressean commented 5 years ago

This PR contains logic fixes to recycle_waifs reproduction steps:

  1. Load stock Lambdacore.
  2. @create #1 called "generic waif",waif
  3. @corify waif as waif
  4. @verb waif:new tnt
  5. @program waif:new
  6. Paste the following code: set_task_perms(caller_perms()); w = new_waif(); w:initialize(); return w;
  7. Once the verb saves, eval $waif:new(); Expected: E_VRBNF; got panic. The issue is that we were previously calling recycled_waifs:erase, which was invalidating the current iterator.
  8. Create a vector which stores a list of all waifs to be recycled. After we mark them for recycle, iterate through that vector and free/remove them from the map.
  9. I also took the opportunity to update the map on both recycled_waifs and waif_class_count to be an unordered_map. These are true hashes (and pointers can be hashed), so the amount of indexing and setting done will be sped up by a decent amount. reproduction steps:
  10. Load stock Lambdacore.
  11. @create #1 called "generic waif",waif
  12. @corify waif as waif
  13. @verb waif:new tnt
  14. @program waif:new
  15. Paste the following code: set_task_perms(caller_perms()); w = new_waif(); w:initialize(); return w;
  16. Once the verb saves, eval $waif:new(); Expected: E_VRBNF; got panic. The issue is that we were previously calling recycled_waifs:erase, which was invalidating the current iterator.
  17. Create a vector which stores a list of all waifs to be recycled. After we mark them for recycle, iterate through that vector and free/remove them from the map.
  18. I also took the opportunity to update the map on both recycled_waifs and waif_class_count to be an unordered_map. These are true hashes (and pointers can be hashed), so the amount of indexing and setting done will be sped up by a decent amount.