-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when comparing daypack and military rucksack #34046
Comments
On that inventory compare crash - inventory_column::prepare_paging erases all the inventory_entry's from entries on a filter change. That leaves compared with an invalid pointer. std::vector<inventory_entry > compared should probably be an item (i.e. inventory_entry->locations->front()->get_item() ) |
fixed by #36139 |
Not fixed yet. |
my apologies, misread it |
confirmed. still happening, on Linux at least. |
can we revive the proposed fix direction in #36139 ? |
Fixes CleverRaven#34046. Using the search filter causes all the inventory_entry objects to be recreated, so it's not safe to store a pointer to them. A previous attempt to solve this (CleverRaven#36139) stored copies of the inventory_entry objects, but that was also unsafe. This attempt instead stores just pointers to the underlying items. This seems to prevent the crashes. The behaviour of the window is still not always exactly correct, because using the filter will violate the invariant that the items in the compared vector correspond to the selected entries. I don't see a way to fix that in general -- sometimes the compared item is filtered out, and thus you can't possibly select the entry (because it doesn't exist). We might want to add something that does its best to select the right entries when the filter changes, but this is a sufficiently niche use case that I'm not sure it's worth the complexity. I've settled for just fixing the crash for now.
Fixes CleverRaven#34046. Using the search filter causes all the inventory_entry objects to be recreated, so it's not safe to store a pointer to them. A previous attempt to solve this (CleverRaven#36139) stored copies of the inventory_entry objects, but that was also unsafe. This attempt instead stores just pointers to the underlying items. This seems to prevent the crashes. The behaviour of the window is still not always exactly correct, because using the filter will violate the invariant that the items in the compared vector correspond to the selected entries. I don't see a way to fix that in general -- sometimes the compared item is filtered out, and thus you can't possibly select the entry (because it doesn't exist). We might want to add something that does its best to select the right entries when the filter changes, but this is a sufficiently niche use case that I'm not sure it's worth the complexity. I've settled for just fixing the crash for now.
Fixes #34046. Using the search filter causes all the inventory_entry objects to be recreated, so it's not safe to store a pointer to them. A previous attempt to solve this (#36139) stored copies of the inventory_entry objects, but that was also unsafe. This attempt instead stores just pointers to the underlying items. This seems to prevent the crashes. The behaviour of the window is still not always exactly correct, because using the filter will violate the invariant that the items in the compared vector correspond to the selected entries. I don't see a way to fix that in general -- sometimes the compared item is filtered out, and thus you can't possibly select the entry (because it doesn't exist). We might want to add something that does its best to select the right entries when the filter changes, but this is a sufficiently niche use case that I'm not sure it's worth the complexity. I've settled for just fixing the crash for now.
Game version: 0.D-7603-g1b96ad13c5-dirty
(but I didn't change anything related to encumbrance in my local build)
Operating system: macOS 10.13.6
Tiles or curses: Tiles
Mods active:
Expected behavior
Don't crash when comparing items
Actual behavior
SIGSEGV with
Steps to reproduce the behavior
In a new world, spawn a military rucksack and a daypack. Wear the military rucksack. Then press I to compare items, and use the search function / to search for "mil", press enter to confirm the search, and press right arrow to select the rucksack you're wearing. Then press / again, search for "day", press enter to confirm the search, then press right arrow to select the daypack. The game will crash before it shows the comparison screen.
This is 100% reproducible for me.
The text was updated successfully, but these errors were encountered: