Skip to content

scripts/ban-cooking.rb can cause crashes - pull request submitted #995

Closed

Description

@rndmvar

DFHack/scripts#6 (link fixed)

Specific items addressed by an issue:

  1. All ban-able items must be cook-able to be banned.
  2. 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.
  3. Change the index variable in the ban_cooking function from a key lookup to a numerical index value
  4. 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...

Activity

  1. added this to the 0.43.05-r1 milestone on Sep 15, 2016
  2. self-assigned this
    on Sep 15, 2016
  3. PeridexisErrant commented on Sep 18, 2016

    @PeridexisErrant
    Contributor

    For cross-repo links, you can write DFHack/scripts#6 - the identifying slug, then the pull or issue number.

  4. lethosor commented on Sep 18, 2016

    @lethosor
    Member

    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.

  5. rndmvar commented on Sep 18, 2016

    @rndmvar
    Author

    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.

  6. lethosor commented on Oct 5, 2016

    @lethosor
    Member

    Merged.

  7. lethosor commented on Oct 5, 2016

    @lethosor
    Member

    Reopening per comment on DFHack/scripts@7f53693

  8. removed this from the 0.43.05-r1 milestone on Feb 24, 2017
  9. lethosor commented on Apr 14, 2020

    @lethosor
    Member

    The original issue here seems to have been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions