DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.88k stars 478 forks source link

spawnunit causing immediate crashes #1937

Open nocpur opened 3 years ago

nocpur commented 3 years ago

Version: 0.47.05-r2

Even throughout previous versions (currently using latest) spawnunit causes immediate crashes. I cannot reliably reproduce these crashes because, although 90% of the time using the command results in a crash, it can work. This happens regardless of save.

1798 is similar to my situation, but with the recent release I have only had a handful of successful attempts.

All I am running is -spawnunit [name] [caste]. I am usually testing modded creatures with this, which are stable and have no errors in DF's errorlog. However, vanilla creatures cause crashes too. I have been able to spawn a creature successfully, save the game, and continue playing in the past with no further issues.

When I spawn the creature, the game will usually CTD as soon as I unpause. Sometimes, though more rarely, it is immediate and no unpause is needed. I am unsure what allows a successful spawn.

While spawnunit has worked but does not generate an error, modtools/create-unit does provide some error text, does not spawn a creature, and does not cause a crash.

I'm unfamiliar with github and have created an account just for this problem, but I'll do my best. If you need anything from me, just let me know and I would be glad to help.

lethosor commented 3 years ago

What platform are you using? Could you copy the errors you mentioned and paste them here?

nocpur commented 3 years ago

Using Windows 10. Also, my bad, I was using modtools/create-unit incorrectly so that would explain the error message there. Using that command, I have successfully spawned something without crashing (immediately, that is, it took a minute or two. Eventually there was a CTD, though a second attempt has not yet crashed) but spawn-unit still does not work.

EDIT: Second attempt crashed. Third attempt crashed immediately.

lethosor commented 3 years ago

They should behave consistently, because spawnunit calls modtools/create-unit directly (here). If you pass command as the first argument to spawnunit, you'll see the actual command it's running. For example:

[DFHack]# spawnunit command CAT MALE

prints:

modtools/create-unit -race CAT -caste MALE -location [ 78 39 87 ]

Can you give a couple specific examples of commands that are crashing? Also, can you try the corresponding modtools/create-unit commands?

I am also curious if this is somehow a save-specific issue. If you could try in a different save (or saves), that would be great. I'm not sure whether an unmodded save would be more useful, but it might also be good to test as a point of reference.

For reference, I ran spawnunit CAT MALE and spawnunit CAT FEMALE 5 times each in an unmodded 0.47.05 save on Linux and experienced no crashes. They did get into fights with nearby dogs, which is a bit weird because I already had stray cats that weren't getting into fights, but other than that, I didn't notice any odd behavior or crashes.

nocpur commented 3 years ago

Yup! Here's some things I have found out.

  1. Here's some instances of commands I've been running.

All of which have caused crashes. Right now, I haven't had any crashes yet, but these are the exact commands I have been using before. Usually once one crash happens, I cannot get any more successful spawning attempts.

  1. This happens regardless of save. I have updated DFHack/my DF version several times throughout a year or two, and this has been an issue for as long as I have used this command.

  2. Sometimes it seems closing dwarf fortress and leaving it closed for a while results in more successful spawn attempts. I always notice that my first spawn after leaving DF closed for a while usually succeeds with no crashes, but if I close the game and retry it does not.

On that note, I am using the "die" command to close without saving because I mostly use spawning for testing.

  1. Also, this is unrelated to crashing, but the fighting is something I've noticed before. Spawning a large predator and taming it (not through commands) will result in the military attacking it if on active duty, even if tamed/trained, kind of like they would a tamed megabeast. But if you let the creatures breed, their offspring do not get attacked by the military.
lethosor commented 3 years ago

Another thing I forgot to ask: what game mode are you using? (Fortress mode, adventure mode, arena, etc.)

nocpur commented 3 years ago

Fortress mode.