Skip to content
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

StoneSense crashes on DFHack 0.47.03-beta1 #68

Closed
Gladuin opened this issue Mar 4, 2020 · 28 comments
Closed

StoneSense crashes on DFHack 0.47.03-beta1 #68

Gladuin opened this issue Mar 4, 2020 · 28 comments
Assignees
Labels
Projects

Comments

@Gladuin
Copy link

Gladuin commented Mar 4, 2020

Hello,

A crash occurs upon loading StoneSense in DFHack 0.47.03-beta1 on Windows 10.
Here is my stderr.log:

DFHack build: 0.47.03-beta1-0-gfb6dd691
Identifying DF version.
Loading hack\symbols.xml ... OK
v0.47.03 SDL win32 (windows): PE: 0x5E4916E0
v0.47.03 SDL win64 (windows): PE: 0x5E491E82
v0.47.03 linux32 (linux): MD5: d64e00ffa0be385c2f94a40392d065e6
v0.47.03 linux64 (linux): MD5: 0f184a432dc8b09af70169537e8000b8
v0.47.03 osx32 (darwin): MD5: 99b655b646e355a115504d89fc5e15a9
v0.47.03 osx64 (darwin): MD5: cd5ef8c61e892f0fec8065353534aee7
Loaded 6 DF symbol tables.
Version: v0.47.03 SDL win64
Initializing Console.
Console is running.
Initializing Plugins.
loading plugin 3dveins
loaded plugin 3dveins; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin add-spatter
loaded plugin add-spatter; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autochop
loaded plugin autochop; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autoclothing
loaded plugin autoclothing; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autodump
loaded plugin autodump; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autofarm
loaded plugin autofarm; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autogems
loaded plugin autogems; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autohauler
loaded plugin autohauler; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autolabor
loaded plugin autolabor; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin automaterial
loaded plugin automaterial; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin automelt
loaded plugin automelt; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin autotrade
loaded plugin autotrade; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin blueprint
loaded plugin blueprint; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin building-hacks
loaded plugin building-hacks; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin buildingplan
loaded plugin buildingplan; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin burrows
loaded plugin burrows; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin changeitem
loaded plugin changeitem; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin changelayer
loaded plugin changelayer; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin changevein
loaded plugin changevein; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin cleanconst
loaded plugin cleanconst; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin cleaners
loaded plugin cleaners; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin cleanowned
loaded plugin cleanowned; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin command-prompt
loaded plugin command-prompt; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin confirm
loaded plugin confirm; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin createitem
loaded plugin createitem; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin cursecheck
loaded plugin cursecheck; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin cxxrandom
loaded plugin cxxrandom; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin debug
loaded plugin debug; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin deramp
loaded plugin deramp; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin dig
loaded plugin dig; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin digFlood
loaded plugin digFlood; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin diggingInvaders
loaded plugin diggingInvaders; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin dwarfmonitor
loaded plugin dwarfmonitor; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin dwarfvet
loaded plugin dwarfvet; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin embark-assistant
loaded plugin embark-assistant; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin embark-tools
loaded plugin embark-tools; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin eventful
loaded plugin eventful; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin fastdwarf
loaded plugin fastdwarf; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin filltraffic
loaded plugin filltraffic; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin fix-armory
loaded plugin fix-armory; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin fix-unit-occupancy
loaded plugin fix-unit-occupancy; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin fixveins
loaded plugin fixveins; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin flows
loaded plugin flows; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin follow
loaded plugin follow; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin forceequip
loaded plugin forceequip; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin fortplan
loaded plugin fortplan; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin generated-creature-renamer
loaded plugin generated-creature-renamer; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin getplants
loaded plugin getplants; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin hotkeys
loaded plugin hotkeys; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin infiniteSky
loaded plugin infiniteSky; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin isoworldremote
loaded plugin isoworldremote; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin jobutils
loaded plugin jobutils; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin labormanager
loaded plugin labormanager; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin lair
loaded plugin lair; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin liquids
loaded plugin liquids; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin luasocket
loaded plugin luasocket; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin manipulator
loaded plugin manipulator; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin map-render
loaded plugin map-render; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin misery
loaded plugin misery; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin mode
loaded plugin mode; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin mousequery
loaded plugin mousequery; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin nestboxes
loaded plugin nestboxes; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin orders
loaded plugin orders; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin pathable
loaded plugin pathable; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin petcapRemover
loaded plugin petcapRemover; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin plants
loaded plugin plants; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin power-meter
loaded plugin power-meter; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin probe
loaded plugin probe; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin prospector
loaded plugin prospector; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin regrass
loaded plugin regrass; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin RemoteFortressReader
loaded plugin RemoteFortressReader; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin rename
loaded plugin rename; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin rendermax
loaded plugin rendermax; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin resume
loaded plugin resume; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin reveal
loaded plugin reveal; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin ruby
loaded plugin ruby; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin search
loaded plugin search; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin seedwatch
loaded plugin seedwatch; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin showmood
loaded plugin showmood; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin siege-engine
loaded plugin siege-engine; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin sort
loaded plugin sort; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin steam-engine
loaded plugin steam-engine; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin stockflow
loaded plugin stockflow; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin stockpiles
loaded plugin stockpiles; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin stocks
loaded plugin stocks; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin stonesense
loaded plugin stonesense; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin strangemood
loaded plugin strangemood; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin tailor
loaded plugin tailor; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin tiletypes
loaded plugin tiletypes; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin title-folder
loaded plugin title-folder; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin title-version
loaded plugin title-version; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin trackstop
loaded plugin trackstop; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin tubefill
loaded plugin tubefill; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin tweak
loaded plugin tweak; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin workflow
loaded plugin workflow; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin workNow
loaded plugin workNow; DFHack build 0.47.03-beta1-0-gfb6dd691
loading plugin zone
loaded plugin zone; DFHack build 0.47.03-beta1-0-gfb6dd691
Starting the TCP listener.
Starting IO thread.
Starting DF input capture thread.
Listening on port 5000
DFHack is running.
Invoking: keybinding add Ctrl-F1 hotkeys
Invoking: keybinding add Alt-F1 hotkeys
Invoking: keybinding add Ctrl-W twaterlvl
Invoking: keybinding add Ctrl-V digv
Invoking: keybinding add Ctrl-Shift-V "digv x"
Invoking: keybinding add Ctrl-C spotclean
Invoking: keybinding add Ctrl-Shift-K autodump-destroy-here
Invoking: keybinding add Alt-Shift-I@dwarfmode/Zones "zone set"
Invoking: keybinding add Ctrl-K autodump-destroy-item
Invoking: keybinding add Ctrl-Alt-S@dwarfmode/Default quicksave
Invoking: keybinding add Ctrl-Shift-N gui/rename
Invoking: keybinding add Ctrl-Shift-T "gui/rename unit-profession"
Invoking: keybinding add Ctrl-Shift-P command-prompt
Invoking: keybinding add Alt-M@dwarfmode/Default "dwarfmonitor prefs"
Invoking: keybinding add Ctrl-F@dwarfmode/Default "dwarfmonitor stats"
Invoking: keybinding add Ctrl-Shift-F@dwarfmode forum-dwarves
Invoking: keybinding add Alt-S@title gui/settings-manager
Invoking: keybinding add Alt-S@dwarfmode/Default gui/settings-manager
Invoking: keybinding add Alt-Q@jobmanagement/Main gui/manager-quantity
Invoking: keybinding add Ctrl-Shift-R view-unit-reports
Invoking: keybinding add Alt-I@dwarfmode/ViewUnits|unitlist gui/unit-info-viewer
Invoking: keybinding add Ctrl-B@dungeonmode adv-bodyswap
Invoking: keybinding add Ctrl-Shift-B@dungeonmode "adv-bodyswap force"
Invoking: keybinding add Shift-O@dungeonmode gui/companion-order
Invoking: keybinding add Ctrl-T@dungeonmode gui/advfort
Invoking: keybinding add Ctrl-A@dungeonmode/ConversationSpeak adv-rumors
Invoking: keybinding add Ctrl-A@legends "exportlegends all"
Invoking: keybinding add Ctrl-Shift-Z@dwarfmode/Default "stocks show"
Invoking: keybinding add Ctrl-Shift-I@dwarfmode/Default "gui/dfstatus"
Invoking: keybinding add Ctrl-Shift-I@dfhack/lua/dfstatus "gui/dfstatus"
Invoking: keybinding add Alt-P copystock
Invoking: keybinding add Alt-L@dwarfmode/QueryBuilding/Some/Stockpile "gui/stockpiles -load"
Invoking: keybinding add Alt-S@dwarfmode/QueryBuilding/Some/Stockpile "gui/stockpiles -save"
Invoking: keybinding add Ctrl-D job-duplicate
Invoking: keybinding add Shift-A "job-material ALUNITE"
Invoking: keybinding add Shift-M "job-material MICROCLINE"
Invoking: keybinding add Shift-D "job-material DACITE"
Invoking: keybinding add Shift-R "job-material RHYOLITE"
Invoking: keybinding add Shift-I "job-material CINNABAR"
Invoking: keybinding add Shift-B "job-material COBALTITE"
Invoking: keybinding add Shift-O "job-material OBSIDIAN"
Invoking: keybinding add Shift-T "job-material ORTHOCLASE"
Invoking: keybinding add Shift-G "job-material GLASS_GREEN"
Invoking: keybinding add Alt-Shift-N "sort-units name" "sort-items description"
Invoking: keybinding add Alt-Shift-R "sort-units arrival"
Invoking: keybinding add Alt-Shift-T "sort-units profession" "sort-items type material"
Invoking: keybinding add Alt-Shift-Q "sort-units squad_position" "sort-items quality"
Invoking: keybinding add Ctrl-M@dwarfmode/QueryBuilding/Some gui/mechanisms
Invoking: keybinding add Alt-R@dwarfmode/QueryBuilding/Some gui/room-list
Invoking: keybinding add Alt-L@dwarfmode/LookAround gui/liquids
Invoking: keybinding add Ctrl-Shift-M@dwarfmode/Build/Position/Trap gui/power-meter
Invoking: keybinding add Alt-A@dwarfmode/QueryBuilding/Some/SiegeEngine gui/siege-engine
Invoking: keybinding add Ctrl-W@layer_military/Equip/Customize/View gui/choose-weapons
Invoking: keybinding add Ctrl-C@layer_military/Uniforms gui/clone-uniform
Invoking: keybinding add Alt-P@dwarfmode/Hauling/DefineStop/Cond/Guide gui/guide-path
Invoking: keybinding add Alt-A@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workshop-job
Invoking: keybinding add Alt-W@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workflow
Invoking: keybinding add Alt-W@overallstatus "gui/workflow status"
Invoking: keybinding add Alt-W@dfhack/lua/status_overlay "gui/workflow status"
Invoking: keybinding add Shift-B@pet/List/Unit "gui/autobutcher"
Invoking: keybinding add P@dwarfmode/QueryBuilding/Some/Weaponrack gui/assign-rack
Invoking: keybinding add Alt-Shift-P@dwarfmode/LookAround gui/pathable
Invoking: tweak stable-cursor
Enabled tweak stable-cursor (stable_cursor_hook::feed)
Invoking: tweak advmode-contained
Enabled tweak advmode-contained (advmode_contained_hook::feed)
Invoking: tweak fast-trade
Enabled tweak fast-trade (fast_trade_assign_hook::feed)
Enabled tweak fast-trade (fast_trade_select_hook::feed)
Invoking: tweak military-stable-assign
Enabled tweak military-stable-assign (military_assign_hook::feed)
Invoking: tweak military-color-assigned
Enabled tweak military-color-assigned (military_assign_hook::render)
Invoking: tweak craft-age-wear
Enabled tweak craft-age-wear (craft_age_wear_hook::ageItem)
Invoking: tweak farm-plot-select
Enabled tweak farm-plot-select (farm_select_hook::feed)
Enabled tweak farm-plot-select (farm_select_hook::render)
Invoking: tweak import-priority-category
Enabled tweak import-priority-category (takerequest_hook::feed)
Enabled tweak import-priority-category (takerequest_hook::render)
Invoking: tweak condition-material
Enabled tweak condition-material (condition_material_hook::feed)
Invoking: tweak hotkey-clear
Enabled tweak hotkey-clear (hotkey_clear_hook::feed)
Enabled tweak hotkey-clear (hotkey_clear_hook::render)
Invoking: tweak embark-profile-name
Enabled tweak embark-profile-name (embark_profile_name_hook::feed)
Invoking: tweak block-labors              # Prevents labors that can't be used from being toggled
Enabled tweak block-labors (block_labors_hook::feed)
Enabled tweak block-labors (block_labors_hook::render)
Invoking: tweak burrow-name-cancel
Enabled tweak burrow-name-cancel (burrow_name_cancel_hook::feed)
Invoking: tweak cage-butcher
Enabled tweak cage-butcher (cage_butcher_hook::feed)
Enabled tweak cage-butcher (cage_butcher_hook::render)
Invoking: tweak civ-view-agreement
Enabled tweak civ-view-agreement (civ_agreement_view_hook::render)
Invoking: tweak eggs-fertile
Enabled tweak eggs-fertile (egg_fertile_hook::render)
Invoking: tweak fps-min
Enabled tweak fps-min (fps_min_hook)
Invoking: tweak hide-priority
Enabled tweak hide-priority (hide_priority_hook::feed)
Enabled tweak hide-priority (hide_priority_hook::render)
Invoking: tweak kitchen-prefs-all
Enabled tweak kitchen-prefs-all (kitchen_prefs_all_hook::feed)
Enabled tweak kitchen-prefs-all (kitchen_prefs_all_hook::render)
Invoking: tweak kitchen-prefs-empty
Enabled tweak kitchen-prefs-empty (kitchen_prefs_empty_hook::render)
Invoking: tweak max-wheelbarrow
Enabled tweak max-wheelbarrow (max_wheelbarrow_hook::render)
Enabled tweak max-wheelbarrow (max_wheelbarrow_hook::feed)
Invoking: tweak shift-8-scroll
Enabled tweak shift-8-scroll (shift_8_scroll_hook::feed)
Invoking: tweak stone-status-all
Enabled tweak stone-status-all (stone_status_all_hook::feed)
Enabled tweak stone-status-all (stone_status_all_hook::render)
Invoking: tweak title-start-rename
Enabled tweak title-start-rename (title_start_rename_hook::feed)
Enabled tweak title-start-rename (title_start_rename_hook::render)
Invoking: tweak tradereq-pet-gender
Enabled tweak tradereq-pet-gender (pet_gender_hook::render)
Invoking: enable title-version
Invoking: enable search
Invoking: enable automaterial
Invoking: enable  confirm  dwarfmonitor  mousequery  autogems  automelt  autotrade  buildingplan  resume  trackstop  zone  stocks  autochop  stockpiles
Invoking: embark-tools enable sticky sand mouse
Invoking: enable embark-assistant
Invoking: modtools/extra-gamelog enable
Invoking: enable gui/extended-status
Invoking: view-item-info enable
Invoking: gui/load-screen enable
Invoking: sc-script add SC_WORLD_LOADED onLoad.init-example
UNKNOWN CLASS 'dfhack_lua_viewscreen@DFHack': vtable = 0x7ff9afbd08d0
Invoking: gui/prerelease-warning
loaded map in prerelease build
Invoking: repeat -name warn-starving -time 10 -timeUnits days -command [ warn-starving ]
Invoking: warn-starving
Invoking: ssense
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: out-of-date sRGB profile with no signature
Client connection established.
Shutting down client connection.

EDIT: This also seems to happen on 0.44.12-r3

@lethosor lethosor transferred this issue from DFHack/dfhack Mar 10, 2020
@lethosor lethosor added the Crash label Mar 10, 2020
@shawntan
Copy link

I'm getting this error on running dfhack in the terminal, then stonesense:

.dwarffortress/dfhack: line 89: 281534 Segmentation fault      (core dumped) setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./libs/Dwarf_Fortress "$@"

The version of dfhack I'm using is DFHack version 0.47.04-beta1 (release) on x86_64, and my system is Linux archlinux 5.6.3-arch1-1 #1 SMP PREEMPT Wed, 08 Apr 2020 07:47:16 +0000 x86_64 GNU/Linux.

The issue seems to be exactly the same as: DFHack/dfhack#1521 (comment)

@shawntan
Copy link

Same issue on DFHack version 0.47.04-r1 (release) on x86_64

@lethosor
Copy link
Member

Yeah, Stonesense hasn't been meaningfully changed in almost a year. I'm not sure if this issue is due to something that changed in 0.47 that DFHack hasn't caught yet (which would be surprising at this point, but fixable), an issue that needs to be addressed on the Stonesense side (which would be unlikely to happen any time soon unless someone steps up to maintain Stonesense), or something related to newer systems (in which case I would expect at least some more detail in stderr.log).

You wouldn't happen to have a stack trace from this to narrow it down, would you? If you have GDB installed, you could run ./dfhack -g to attach GDB and hopefully generate one when it crashes.

@jeancallisti
Copy link

jeancallisti commented Apr 29, 2020

It's a memory corruption from something being loaded improperly as soon as stonesense tries to initialize its assets:

stonesense.plug.dll!std::operator==<ItemConfiguration,std::default_delete>(const std::unique_ptr<ItemConfiguration,std::default_delete> & _Left, void * __formal) Line 2657 C++
stonesense.plug.dll!parseItemElement(TiXmlElement * elemRoot, int basefile) Line 83 C++
stonesense.plug.dll!addSingleItemConfig(TiXmlElement * elemRoot) Line 32 C++
stonesense.plug.dll!ContentLoader::parseItemContent(TiXmlElement * elemRoot) Line 561 C++
stonesense.plug.dll!ContentLoader::parseContentXMLFile(const char * filepath) Line 497 C++
stonesense.plug.dll!ContentLoader::parseContentIndexFile(const char * filepath) Line 431 C++
stonesense.plug.dll!ContentLoader::parseContentIndexFile(const char * filepath) Line 436 C++

the filepath is : stonesense\items\index.txt

EDIT: grei_items.png is the culprit.
At first I thought it might be because of the space in the subfolder's name so I replaced it with underscore, and I also try to open and re-save the PNG as 8-bits colors instead of 32-bits colors.
But neither helped.

@jeancallisti
Copy link

jeancallisti commented Apr 30, 2020

I think it crashes because of this :

  • In stonesense/items/greiger_items/greiger_items.xml, The XML loader successfully loads the attributes of item "BIN" and identifies that it's main_type 31.
  • But then somehow when the game tries to access contentLoader->itemConfigs[main_type] , itemConfigs has a capacity of 0. You can't access cell 31 in an array or vector that has zero cells.

What I don't understand though, is why the array is not enlarged beforehand.
ItemConfiguration seems to be managed in an different way than, for example, CreatureConfiguration, which has a "push" mechanism instead of just accessing the cells by index.

@shawntan
Copy link

shawntan commented May 1, 2020

DFHack/dfhack#1521 (comment) also reaches the same conclusion.

@RosaryMala
Copy link
Member

I'll try to get this fixed.

@RosaryMala
Copy link
Member

29b430d broke this by removing the part where it makes sure that the item array is the right length.

@jeancallisti
Copy link

Not sure you're quoting the correct commit, as the one you quoted mentions TerrainMaterialConfiguration, whereas this issue is with ItemConfiguration ? (Even though the logic does seem similar and does seem to have been broken)

@RosaryMala
Copy link
Member

Oh, he changed a bunch of things, but I realized that his specific chances weren't what was causing it. Still trying to make sure I caught everything, 5b7e774 may fix it.

@jeancallisti
Copy link

jeancallisti commented May 3, 2020

Your change does two things :

  1. You changed the way the resizing is done
  • the way it was done before : if the vector is too small, clear it entirely then push null into the vector until it reaches the required size.
  • The way you're doing it : if the vector is too small, use .resize to enlarge it, then put null into every cell.

This first change is not really necessary. EDIT: It is necessary

  1. You change the size of the array to ENUM_LAST_ITEM(item_type) +1 instead of ENUM_LAST_ITEM(item_type)

I think that's the solution to our issue. Before, if we encountered an item type which enum was going up to, let's say, 31, then we would resize the array to 31 instead of 32. Which means we could never go up to the cell at index 31! That was clearly a bug that needed to be fixed.

I shall end with a sour comment about how once again when looking at C++ code, there's a fatal bug in a simple operation because someone thought they were too smart to just use off-the-shelf, one-liner array primitives... and made a mistake in their custom 10-lines replacement. ;)

@jeancallisti
Copy link

jeancallisti commented May 4, 2020

I've tested it. It works.
Contrary to what I said, both changes are needed. And I cant explain why this works...

if (config.size() != (ENUM_LAST_ITEM(item_type) + 1))
    config.resize(ENUM_LAST_ITEM(item_type) + 1);
for (size_t i = 0; i < config.size(); i++)
{
    config[i] = nullptr;
}

...while this crashes :

uint32_t currentsize = (uint32_t)config.size();

if (currentsize < ENUM_LAST_ITEM(item_type) +1) {
    currentsize = ENUM_LAST_ITEM(item_type) +1;
}
config.clear();
while (currentsize < config.size()) {
    config.push_back(nullptr);

@RosaryMala
Copy link
Member

This is why I hate C++.

@lethosor
Copy link
Member

lethosor commented May 4, 2020

config = vector<whatever_type>(ENUM_LAST_ITEM(item_type) + 1, nullptr) would probably be less error-prone than either of those

@jeancallisti
Copy link

Ha ha I love how the hardened C++ dev answers "this would be less error-prone" rather than "look, those 10 lines are now one, I used a built-in function".

@lethosor
Copy link
Member

lethosor commented May 4, 2020

I mean, re-implementing built-in operations usually is more error-prone regardless of the language. I'm more inclined to blame the logic here rather than the language itself.

Looking again at the two snippets you posted, the main difference I'm seeing is that the first one (which you said works) resizes config to be exactly the desired size, while the second one resizes it to be at least the desired size - if it was larger before, it will still be larger. Just by looking at it, I don't see any way that it can crash by itself, but it could probably affect other parts of Stonesense in difficult-to-predict ways. (I would have guessed that the first snippet would be more likely to result in a crash later on, but it's hard to say without more context.)

Casting currentsize from a size_t to a uint32_t (which is sometimes smaller) is inadvisable, but probably unlikely to trigger any issues for smaller vectors.

Edit: oh, I think I see the issue in the second snippet - currentsize is the desired size of the vector (it's a misleading name IMO), so if it's set to e.g. 5, it will never be smaller than config.size() after config.clear() is called (5 < 0 is false, so the body of the while loop will never run).

@RosaryMala
Copy link
Member

I'm all for using the actual builtin function for this.

@RosaryMala
Copy link
Member

Also DFhack really should have a ENUM_SIZE macro.

@jeancallisti
Copy link

jeancallisti commented May 4, 2020

Ah yes, indeed, it should be while(config.size()<currentSize ) , not while(currentsize < config.size()).
Mystery solved!

But that can be dumped altogether if the one-liner is used. So yes, I vote for that.

@RosaryMala not to be lazy but can you check that this way of doing things is not used in other XXXConfiguration.cpp files?

@RosaryMala
Copy link
Member

Yeah, I'll take a look at the rest of the things and make sure they're all working.

@deadundead
Copy link

deadundead commented Jun 21, 2020

5b7e774
Can confirm this works.
I've managed to build DFHack, with stonesense checkout to this commit, against a last version of Lazy Mac Pack (v0.47.04).
It still crashes on any attemp to resize the window, but if you don't change it after launching stonesense it seems to run smoothly.
It is also worth mentioning, that I didn't have xcode installed, XML::LibXML installation threw a bunch of errors and XML::LibXSLT didn't install at all. But i was so desperate that I tried the build, and it was OK.

My first time playing DF =D

Also I see that the keyboard control issue is still unsolved, and won't be?
P.S. would be grateful for tips on bulding twbt, as the one included in the Pack refuses to work with latest build of DFHack.

@lethosor
Copy link
Member

We would probably have to move Stonesense to a standalone process to make keyboard input work (that would have other benefits, like crashes not bringing down DF, but would also need someone familiar with Stonesense and willing to put in the effort).

For reference, I'm pretty sure that the automated builds from https://dfhack.org/builds/ (like this one) include Stonesense.

@DanielLaberge
Copy link

DanielLaberge commented Jun 29, 2020

Until this is fixed, could someone provide a brief walkthrough/workaround on how to get this working with say, the LNP? It would be much appreciated <3

@lethosor
Copy link
Member

If you follow my automated builds link from above, you should get to a page like this (this page may be outdated by the time you click the link, though, so I recommend using the first link instead). Under "Build artifacts", choose the build that matches your DF installation (e.g. "Windows64" for 64-bit Windows DF). Once that file has downloaded, extract "hack/plugins/stonesense.plug.(dll, so, or dylib)" from it and replace the file in your existing hack/plugins folder with it. Generally, when doing this with Stonesense, you should also replace the "stonesense" folder with the downloaded copy, but that shouldn't be necessary in this case. When you start DF, you'll probably see a warning that the plugin was built for a different DFHack build, but as long as it starts with "Warning", it's safe to ignore.

@DanielLaberge
Copy link

Perfect, thank you. I can confirm this works with PeridexisErrant's Starter Pack 0.47.04-r06.

@lc-thomas
Copy link

Doesn't work for me :/

[DFHack]# load stonesense
Plugin stonesense was not built for this version of DFHack.
Plugin: 0.47.04-r1, DFHack: 0.47.03-beta1

@lethosor
Copy link
Member

You need to upgrade to DFHack 0.47.04-r1 (which involves upgrading to DF 0.47.04) - the plugin will only work for that version.

@lethosor
Copy link
Member

lethosor commented Aug 8, 2020

Assuming 5b7e774 fixed this, this should be addressed in 0.47.04-r2. Feel free to open a new issue if problems continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
0.47.04-r2
  
Done
Development

No branches or pull requests

8 participants