You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
scripts/ban-cooking.rb can cause crashes - pull request submitted #995
All ban-able items must be cook-able to be banned.
Checks to ensure that kitchen.exc_types[index] exists before attempting to write to it.
-- Ran into issues with the original script attempting to ban non-cookable plant items, which lead to mismatches in the length of the kitchen.exc_types versus the others.
Change the index variable in the ban_cooking function from a key lookup to a numerical index value
Fixed mill and thread banning, as they referenced local variable 'm', but didn't set it.
-- I don't know if there are any cook-able mill or thread plants...
References work with full links too, though, so they can be more convenient if you have the page open already.
Anyway, just to clarify, which part was actually crashing? It looks like you made a lot of changes, but surely they're not all related to crash prevention.
Correct, they're not all related to crashes. Only items 1-3 and 7 in the pull request, and here in the report. Items 4 and 6 felt like missing functionality, that seemed to be the spirit of the original script. Item 5 was useful both for debugging, and being able to check which items were banned outside of flipping through the kitchen menu each time. Item 8 is simply an addition to the script that isn't necessary, but may be something that a few people would like having. Item number 10 was implemented wholly for debugging and visualization of the memory structure, without which I would not have been able to identify what the subtype flag was referencing.
The crash that lead to this, came about after running the original script and getting an error when it attempted to ban cooking on the potato plant. During debugging I found that it had mistakenly added a cooking ban on a non-cookable item (one of either cave wheat, pig tail, ramie, or something else -- lost my notes on which came first). Which prevented an addition to kitchen.exc_types. This lead to the mismatch in the length of kitchen.exc_types, by leaving it shorter than the others. And that was found after I discovered that index needed to be an array address, instead of the three zipped values.
Upon attempting execution, the script dumped a stack trace to the console, and then crashed when I resumed from a paused game state. I'm not sure where to find out the smoking gun to say for sure that the mismatch in the array length of kitchen.exc_types or having a non cookable plant specifically caused the crash, but it was repeated thrice before I started digging into the script.
So, in summation, the script failed to completely execute a ban of "seeds" and "brew", by dumping a Ruby stack trace when it hit potato plants. Then with an item banned incorrectly, and a mis-sized kitchen.exc_types array, the game crashed after resuming play. (The crash may have come about due to my recurring brew job kicking off, or an immediate check of banned items. I can't say for sure.)
And then, while "mill" and "thread" appear to be useless right now, as there aren't any cookable mill/thread plants that I can see. They both referenced a local variable that had not been initialized.
I can run through it again with more debugging output on the original script late tomorrow morning if you are interested.
Activity
PeridexisErrant commentedon Sep 18, 2016
For cross-repo links, you can write
DFHack/scripts#6- the identifying slug, then the pull or issue number.lethosor commentedon Sep 18, 2016
References work with full links too, though, so they can be more convenient if you have the page open already.
Anyway, just to clarify, which part was actually crashing? It looks like you made a lot of changes, but surely they're not all related to crash prevention.
rndmvar commentedon Sep 18, 2016
Correct, they're not all related to crashes. Only items 1-3 and 7 in the pull request, and here in the report. Items 4 and 6 felt like missing functionality, that seemed to be the spirit of the original script. Item 5 was useful both for debugging, and being able to check which items were banned outside of flipping through the kitchen menu each time. Item 8 is simply an addition to the script that isn't necessary, but may be something that a few people would like having. Item number 10 was implemented wholly for debugging and visualization of the memory structure, without which I would not have been able to identify what the subtype flag was referencing.
The crash that lead to this, came about after running the original script and getting an error when it attempted to ban cooking on the potato plant. During debugging I found that it had mistakenly added a cooking ban on a non-cookable item (one of either cave wheat, pig tail, ramie, or something else -- lost my notes on which came first). Which prevented an addition to kitchen.exc_types. This lead to the mismatch in the length of kitchen.exc_types, by leaving it shorter than the others. And that was found after I discovered that index needed to be an array address, instead of the three zipped values.
Upon attempting execution, the script dumped a stack trace to the console, and then crashed when I resumed from a paused game state. I'm not sure where to find out the smoking gun to say for sure that the mismatch in the array length of kitchen.exc_types or having a non cookable plant specifically caused the crash, but it was repeated thrice before I started digging into the script.
So, in summation, the script failed to completely execute a ban of "seeds" and "brew", by dumping a Ruby stack trace when it hit potato plants. Then with an item banned incorrectly, and a mis-sized kitchen.exc_types array, the game crashed after resuming play. (The crash may have come about due to my recurring brew job kicking off, or an immediate check of banned items. I can't say for sure.)
And then, while "mill" and "thread" appear to be useless right now, as there aren't any cookable mill/thread plants that I can see. They both referenced a local variable that had not been initialized.
I can run through it again with more debugging output on the original script late tomorrow morning if you are interested.
lethosor commentedon Oct 5, 2016
Merged.
lethosor commentedon Oct 5, 2016
Reopening per comment on DFHack/scripts@7f53693
lethosor commentedon Apr 14, 2020
The original issue here seems to have been addressed.