I missed this the first time - with_suspend shouldn't be necessary. Where are you running the script from?
It is a lua script started manually through the dfhack console (link later in post). It forces a pause before calling create-unit.
additionally since this script can be paired with "create-item", the unit can be given another civ, and invader tags, I did a little work creating mini 1 man invaders out of this for a proof of concept script created force invasion, made it about half way through it, but abandoned it when I realized I could effectively call for a 50 man army in waves of 10 and effectively guarantee a crash. So I shelved it until someone with a little better idea of whats going on could fix the crash issues.
I made a similar script that spawns invaders. My scripts fails about half the time when spawning ~60 units with a few pieces of equipment and a few skills. (see
http://www.bay12forums.com/smf/index.php?topic=164458.0 )
I ran some experiments to see how often it fails and which errors I got.
Two of the errors I saw are dfhack related. But the majority are dwarf fortress segfaulting.
Can we get interesting data from a segfault or does the code obfuscation prevent this? Are these errors helpful?
Anyway, here are my experiment results:
* Experiment 1
save: df6/r1
experiment: unpause and spawn (strength=1000, ~60 goblins)
Worked: 6, segfault: 4
* Experiment 2
save: df6/r2
experiment: unpause and spawn (strength=1000, ~60 goblins)
Worked: 8, segfault: 1, free: 1
* Experiment 3
save: df6/r2
experiment: keep paused and spawn (strength=1000, ~60 goblins)
Worked: 6, segfault: 3, gui-loop#1: 1
Errors:
* segfault:
Segmentation fault (core dumped)
* free:
[DFHack]# *** Error in `./libs/Dwarf_Fortress': free(): invalid next size (normal): 0x00007fffc4031b30 ***
Aborted (core dumped)
* gui-loop #1
./hack/lua/gui.lua:177: attempt to compare nil with number
stack traceback:
./hack/lua/gui.lua:177: in method 'inClipGlobalXY'
./hack/lua/gui.lua:408: in method 'getMousePos'
./hack/lua/gui/widgets.lua:384: in method 'onRenderBody'
./hack/lua/gui.lua:460: in method 'render'
./hack/lua/gui.lua:447: in method 'renderSubviews'
./hack/lua/gui.lua:462: in method 'render'
./hack/lua/gui.lua:563: in function <./hack/lua/gui.lua:562>
[C]: in ?
... repeating for ever
Other errors I saw before writing down experimental results:
* linked list
*** Error in `./libs/Dwarf_Fortress': malloc(): smallbin double linked list corrupted: 0x00007fffc4072070 ***
Aborted (core dumped)
* gui loop #2
./hack/lua/gui.lua:158: attempt to perform arithmetic on a nil value (field '?')
stack traceback:
./hack/lua/gui.lua:158: in local 'fun'
./hack/lua/class.lua:98: in upvalue 'invoke_after_rec'
./hack/lua/class.lua:94: in upvalue 'invoke_after_rec'
./hack/lua/class.lua:127: in function <./hack/lua/class.lua:112>
(...tail calls...)
./hack/lua/gui.lua:563: in function <./hack/lua/gui.lua:562>
[C]: in ?
... repeating for ever
Conclusions:
We get many different errors even though the experiments were pretty similarly executed.
I might have seen fewer more errors when spawning units after waiting for 2 seconds after loading a game, but that might just be wishful thinking.
These are very limited experiments. I cannot say if the crash rate is higher or lower with other saves and in other situations.
Do anyone have any ideas for ways to reduce the crash rate?