CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.58k stars 4.16k forks source link

Game crash with the new autoturret system #34831

Closed zeggz closed 4 years ago

zeggz commented 5 years ago

Describe the bug

Game crash when trying to set a vehicule turret to "auto targeting" with the new part installed.

Steps To Reproduce

Have an installed turret chasis with a gun mounted on it and the new autoturret part and try to set the targetting mode to "auto"?

Expected behavior

Not to crash the game, act as before the change to the turret auto targeting.

Versions and configuration

Build #9775 & Build #9779

Additional context

The weapon used is the diamond lance (from vehicule mod i think). The weapon is mounted on a "turret chassis" not a "turret mount" (i don't know the difference in game or if it has a different purpose). The mounted weapon worked perfectly before the PR. My savegame is to big to be posted here (more than 800mo!), here is the crash report :

CRASH LOG FILE: config/crash.log VERSION: 0.D-8585-g4489e25 TYPE: Signal MESSAGE: SIGSEGV: Segmentation fault STACK TRACE: @0x5BD805[cataclysm-tiles.exe+0x1BD805] @0x5BE2D2[cataclysm-tiles.exe+0x1BE2D2] SMPEG_error+0x4B034@0xF9BD90[cataclysm-tiles.exe+0xB9BD90] _C_specific_handler+0x9C@0x77587958[ntdll.dll+0x17958] RtlDecodePointer+0xAD@0x7759812D[ntdll.dll+0x2812D] RtlUnwindEx+0xBBF@0x7758855F[ntdll.dll+0x1855F] KiUserExceptionDispatcher+0x2E@0x775BBCB8[ntdll.dll+0x4BCB8] @0xE0FA81[cataclysm-tiles.exe+0xA0FA81] @0xEA71C0[cataclysm-tiles.exe+0xAA71C0] @0xEB82EC[cataclysm-tiles.exe+0xAB82EC] @0xEBB6D2[cataclysm-tiles.exe+0xABB6D2] @0x6F6D72[cataclysm-tiles.exe+0x2F6D72] @0x6F76C2[cataclysm-tiles.exe+0x2F76C2] @0x71A1F6[cataclysm-tiles.exe+0x31A1F6] @0x6F540D[cataclysm-tiles.exe+0x2F540D] IMG_LoadWEBP_RW+0x614F58@0x16A2B58[cataclysm-tiles.exe+0x12A2B58] @0x4013ED[cataclysm-tiles.exe+0x13ED] @0x4014FB[cataclysm-tiles.exe+0x14FB] BaseThreadInitThunk+0xD@0x774659CD[kernel32.dll+0x159CD] RtlUserThreadStart+0x21@0x7759A561[ntdll.dll+0x2A561]

(First post / bug report, be indulgent with me if something is missing. Love the game, thanks to all contributors!)

Edit : screenshots after updating to illustate the problem (still learning) :

CDDA-BugReport1 CDDA-BugReport2

After mounting the turret control over another turret and then on another vehicule (same world with a test character) : CDDA-BugReport3 CDDA-BugReport4

Here is my modlist (i haven't consider posting it before wich is silly on my part since it's quite over reasonnable... it did not have any detrimental effect before this bug and i am on summer day 54 and done tons of things as my character stats can attest)

[ "dda", "Mining_Mod", "no_npc_food", "alt_map_key", "jack_of_all_trades", "MkMaxxi's Gunslinger Mod", "Anesthesia_Crafting", "antifunguskit", "more_survive_notes", "Survivors_Lost_item", "Bootleg_Walkers", "growable-pots", "dig-canal", "makeshift", "Medieval_Stuff", "More_Survival_Tools", "space_heater", "DracoDogMod", "DracoPigMod", "modular_turrets_no_blacklist", "Salvaged_Robots", "disable_bots", "disable_bots_natcamp", "hydroponics", "log_wall_tweak", "P_Caches", "sarcophagi_access", "ArmUpPAUtil", "ArmUpSurvEx", "basement_extension", "mutant_npcs", "more_locations", "FujiStruct", "mapgen_demo", "national_guard_camp", "bioco", "bio_recipes", "convenientconstructions", "cityside", "Urban_Development", "deoxymod", "blazemod", "Tanks", "more_classes_scenarios", "manualbionicinstall", "safeautodoc", "novitamins", "sleepdeprivation", "speedydex", "StatsThroughSkills", "Tolerate_This", "shardstuff", "Cata++", "magiclysm", "aftershock" ]

Night-Pryanik commented 5 years ago

Can't confirm on 0.D-8616. Installed diamond nova turret on a turret chassis, installed turret control unit over the turret, successfully set its targeting mode to auto and manual.

изображение изображение изображение

zeggz commented 5 years ago

Ok, thanks for your time. I'll do more tests when i can and write here what i discover. Maybe it was because i just installed the new part over a old turret configuration, or something else. My crash was also with a different turret, the one that does'nt require a vortex stone (can't remember the name). There is also a lot of other installed part in this space since it's just above the driver seat, maybe it's some sort of weird interaction. I will also update my game to the last build and see if it's persistent.

zeggz commented 5 years ago

I have updated my description of the problem. I suspect one of the (too) many mods i use to be the culprit since i can confirm it work on a new word with no mod. I'll search wich one and write here what i've found.

PolakAllen commented 5 years ago

I'll just add my crash to the list as well.

image

image

zeggz commented 5 years ago

@PolakAllen Thank for your report, could you post your mod list too? It will help me finding if a mod is badly interacting with the PR and generating the crash.

PolakAllen commented 5 years ago

So, I tried reproducing in various circumstances. So far, the only reproduction I've been able to do is in the original world.

I've tried reproducing on some fresh worlds (no mods + same mods), but no luck so far. Seems like the turret chassis / core is somehow corrupt, which then corrupts the vehicle? That's what the results of my reproduction seem to lead to. If I find a work around I'll post another update

Mod List

``` [ "dda", "no_npc_food", "magiclysm", "ew_pack", "makeshift", "Medieval_Stuff", "More_Survival_Tools", "DinoMod", "DracoDogMod", "secronom", "modular_turrets", "Salvaged_Robots", "Cata++", "MMA", "mutant_npcs", "No_Rail_Stations", "Urban_Development", "more_locations", "deoxymod", "blazemod", "Tanks", "Arcana", "necromancy", "alt_map_key", "FujiStruct", "StatsThroughSkills", "speedydex", "Mutation_Changes", "novitamins", "more_classes_scenarios", "RL_Classes", "aftershock", "Tolerate_This", "crazy_cataclysm", "hydroponics", "Mining_Mod", "cars_to_wrecks", "jury_rigged_robots" ] ```

Reproduction Details

AR-15 on a new vehicle works (forgot battery, added later) ![image](https://user-images.githubusercontent.com/4852396/67120528-51bd5480-f19e-11e9-8233-79fa85db063f.png) Installing the same AR-15 onto the original vehicle ![image](https://user-images.githubusercontent.com/4852396/67120701-a9f45680-f19e-11e9-857e-53cb36e4637f.png) Back to the new vehicle (with battery this time) ![image](https://user-images.githubusercontent.com/4852396/67120888-1707ec00-f19f-11e9-8098-74184603a6e2.png) ![image](https://user-images.githubusercontent.com/4852396/67120945-3272f700-f19f-11e9-9ede-3918f1c8a918.png) With two turrets... hmmm ![image](https://user-images.githubusercontent.com/4852396/67121113-92699d80-f19f-11e9-81be-fc0400d7ccd4.png) Reproduced on the new vehicle when I moved the turret mount from the new. ![image](https://user-images.githubusercontent.com/4852396/67121610-cabdab80-f1a0-11e9-8c19-c62dbe4adb9d.png) Reinstalling the AR-15 on the new vehicle ![image](https://user-images.githubusercontent.com/4852396/67121788-36077d80-f1a1-11e9-8430-f5f939060954.png) Switching back to the original turret chassis and controls scheme ![image](https://user-images.githubusercontent.com/4852396/67122010-ae6e3e80-f1a1-11e9-9fee-4f55fd9d54a7.png)

UNOwenWasMe commented 5 years ago

I have the exact same crash. My modlist is

"dda", "no_npc_food", "crt_expansion", "aftershock", "magiclysm", "craftgp", "FIC_Weapons", "ew_pack", "makeshift", "Medieval_Stuff", "More_Survival_Tools", "DinoMod", "modular_turrets", "Salvaged_Robots", "mutant_npcs", "more_locations", "FujiStruct", "cars_to_wrecks", "blazemod", "Tanks", "jury_rigged_robots", "more_classes_scenarios", "no_reviving_zombies", "safeautodoc", "novitamins", "stats_through_kills"

I've taken some time to manually cross reference our lists

These are the ones that we all share

dda no_npc_food aftershock makeshift Medieval_stuff More_Survival_Tools modular_turrets Salvaged_Robots mutant_npcs more_locations FujiStruct blazemod Tanks more_classes_scenarios novitamins

I will now make a new world with only these mods and see if the crash persists

EDIT:

In my brand new world, made myself god, spawned what I needed; installed the mounts and control units, and everything works as intended. The crash is probably some kind of very strange interaction. I will now experiment with debug in my original world where it crashes.

UNOwenWasMe commented 5 years ago

When I do the same in my old world (spawning in a brand new vehicle and installing it on there), everything works just fine. I doubt it's got anything to do with a mod, but due to how things are handled internally in the vehicle. I will try to find a way to make it work on my Deathmobile by deconstructing it till it doesn't crash anymore.

EDIT: It's actually quite late, so it'll have to wait till later, but what I'm instead gonna do is take a raw vehicle on which the autoturrets work, and modify it till my current configuration and see if/when the crash comes up. Could totally be that the crash doesn't come up... in which case this bug is nasty. But we'll see tomorrow.

UNOwenWasMe commented 5 years ago

Before I go @PolakAllen Have you found a method in your world to "corrupt" your turret mount? Even if the bug doesn't get fixed soon it's still nice to know what to avoid.

(tried to use brand new spanwed turret mounts/control units, still crashes. what the hell is going on? Maybe an issue with vehicles that spawned before the update was made, and all vehicles that spawn in now are fine? If so then this issue should just fade away over time)

After rebuilding my original vehicle piece by piece with debug mode from scratch, everything is fine. Probably an update growing pain, new worlds won't have this issue.

Extra: It just crashed again while loading my stuff into my new car, same crash message, while the turret was on auto...

zeggz commented 5 years ago

So yeah... i've run some test and it's getting weirder than before...

I have dismantled one of my diamond lance and the chassis it was attached on. Then I installed a mount, the lance and finaly the turret control : it just work (to quote a famous game devellopper)! I've been able to change the targetting mode as intended.

Then i've proceed to install the turret control directly on my second lance (mounted on a chassis) and it worked again!

Finally i decided to dismantle this same turret and the control and rebulit it on a newly installed mount, doing the exact same process as for the first one. And then... crash! Just like before!

TurretBug

Note on the screenshot that one of the diamond lance is set to auto from before and when i'd try the second one it crash the game. What is happening here?! There is definitively a weird problem with this new part wich is difficult to reproduce due to it's inconsistency. Maybe it's affecting only old saves, but maybe it could have unforceenable consequences in the future.

Additionaly, after giving some thoughts to the matter, this new part doesn't really make sense due to it's redundancy with the turret mount and componments it require to built. The actual turret mount in the game is ALREADY supposed to be an auto-turret wich have an AI built in as well as a gun operating system and sensor array (we could debate if it's missing a targeting module). I'm giving some thougt about opening a suggestion to change the PR that introduced the turret control to make something more consistent (the automation should be in the support of the weapon, not added atop of it in the first place, with two separte kind of mount, a manual one and a automated one).

I feel that vehicule/turret/robot parts (targeting module, gun operating system, AI, and the like) are kind of all over the place right now, it should be streamlined by determining exactly the role of each part in crafting more complex things. That would make things easier for the player to understand and give a better guideline to the develloppers.

If you have any toughts on the matter i will gladly read them.

edit : see #34923 for another example of this bug

Night-Pryanik commented 5 years ago

The actual turret mount in the game is ALREADY supposed to be an auto-turret wich have an AI built in as well as a gun operating system and sensor array

No, it's not. Turret mount is just a piece of formed metal with rails. It has absolutely no mechanics or electronics parts in it.

zeggz commented 5 years ago

@Night-Pryanik

Sorry, i don't want to be annoying. But I'm just confused now. Here what it says in my game : turret mount

After checking on the item browser online, it's seems to be marked as an Aftershock recipe (aren't they craftable in the base game?) : https://www.cdda-trunk.chezzo.com/turret_mount/craft AI core, gun operating system, small storage battery, sensor array, identification module, power converter, it seems it's a lot of electronics for a simple piece of metal...

And here's the description and recipe for the turret chassis from blaze mod :

A rotating turret, capable of mounting a weapon system. Install a suitable weapon on it as an automated weapon and the vehicle will be able to fire on hostile targets that get too close.

https://www.cdda-trunk.chezzo.com/vpart_turretframe

turret chassis

Note it was designed to be autonomous even in its energy requirement (solar cells are part of the crafting) https://www.cdda-trunk.chezzo.com/turretframe

It is controlled by a targeting AI that can adapt to the usage of whatever weapon that has been loading, with proper programming.

Maybe my confusion is induced by these two mods but since they are mainline mods, something should be done to streamline all this. That's why I was suggesting to have two separate type of weapon mounts for vehicule, a regular manually manned one and a fully automated one for simplicity instead of having an add-on to existing turrets mount.

This discussion is not linked to the bug reported here, maybe it should have it's own place on a separate suggestion topic, but having issues with this new mechanic had me (over)thinking about the consistency and the logic of mounted weapons (for vehicles but also for static turrets and robots, since they should have many ingeneering similarities).

Like i'd said before, i really like the game and it's open-source nature, i'm just trying to contribute a bit in the limit of my nonexistant technical knowlegde, i hope it doesn't make me a jerk... :-)

kevingranade commented 5 years ago

since they are mainline mods, something should be done to streamline all this.

Yes, the mods can be updated to match mainline, but both are currently unmaintained, so someone needs to volunteer to do that.

zeggz commented 5 years ago

Ok thanks @kevingranade for the clarification. That too bad they're not maintained actually. They are pretty fun to play with.

I've read something here about merging some mods (fully or partially) into the base game and i wonder if it could be done here. I mean blaze mod has some part maybe too weird for the base game (blob vehicules and diamonds launching weapons for example) but other are pretty much realistic. And concerning Aftershock i know it's supposed to be for content too futuristic/sci-fi for the base game but i have difficulties to see where the line is draw since it already have powerfull laser weapons and Mech suits...

Again, this have no link to the bug that lead to the creation of this topic.

anothersimulacrum commented 5 years ago

AFAIK, all the easy stuff to add from Blazemod has been merged - leaving only things that require additional code support or substantial work (and a good deal will just never fit).

zeggz commented 5 years ago

Just some update on this bug.

I've been able to play for a while now with functionning autoturrets after many attempts but if i change configuration on my mounted weapons the crash appears at random. So this bug is really random, without an identifiable cause... too bad for old saves but if it doesn't happens on new saves i guess it will do.

sdp0et commented 4 years ago

I commented in #35434 before realizing it probably applied to this more. I linked to the comment in case the details are useful (like the weapon in the mount being damaged at one point), but in summary I was able to temporarily fix it by un/reinstalling the weapon.

bostrr commented 4 years ago

Been getting the same error for a while now. I have managed to get rid of it a couple of times by removing all guns and turret controls and re installing them while setting them one by one on auto mode. At this point all is working but if I go ahead and install another turret control on my M2 and try to switch to auto mode the game will crash. But also the A7 and Creberus have all done the same thing one time or another.

On linux I get no debug info whatsoever, the game just freezes and I have to send a couple SIGKILLs to close it.

My save is less than a month old on experimental and the only loaded mods are: disable npc needs, no fungal monsters.

Again, try removing all turrets and control units and re-installing them selecting auto fire one by one. I believe this solves the problem temporarily until something must get corrupt again.

scrot-20191111-215343

raeflondon commented 4 years ago

I can reproduce this in 0.D-9376-gb17746f:

  1. spawn new world
  2. spawn humvee
  3. raise all skills to 10, spawn in welding goggles, welding tank, acetylene torch, screwdriver set
  4. spawn in two turrent mounts, one M2HB, one handheld laser
  5. install both turret mounts
  6. install both M2HB and handheld laser
  7. spawn in/install turret control unit on handheld laser
  8. attempt to change targeting mode of handheld laser to auto using vehicle controls
  9. segfault vehicle::turrets_set_targeting()
Night-Pryanik commented 4 years ago

I found the culprit, that's my fault. The crash happens when there are more turrets than control units. For example vehicle has 3 turrets but only one TCU, on 3rd turret.

https://github.com/CleverRaven/Cataclysm-DDA/blob/d0db81ddd665b84a627fc254f8886ab371038d96/src/turret.cpp#L297-L304

turret_controls counts how many TCUs in total we have in our vehicle. In our example we have only one TCU, so this vector contains only one element.

https://github.com/CleverRaven/Cataclysm-DDA/blob/d0db81ddd665b84a627fc254f8886ab371038d96/src/turret.cpp#L331-L334

Then we're trying to toggle the third turret's targeting mode. As sel value is 3, we're trying to call the third element of the one-element vector and thus going out of bounds, which causes the crash.