Cataclysm-dda: Interacting with 7.62.51mm M80 Ammo Belt Segmentation Error

Created on 21 Nov 2020  路  13Comments  路  Source: CleverRaven/Cataclysm-DDA

Describe the bug

Trying to make an ammo belt with the ammo causes crash.
Trying to load a mounted gun with this ammo belt causes crash.

Steps To Reproduce

Give yourself some 7.62.51mm M80 Ammo, and some .308 ammo linkages and try to make an ammo belt.
Or try to reload a mounted M60 gun with the ammo belt.

Expected behavior

For it to not crash.

Screenshots

image
image
image

Versions and configuration

debug.log

Crash Log

crash.log

SAVE IS TOO BIG HERE IS A DRIVE LINK
https://drive.google.com/file/d/1TV-aX3hGBUmUEP1RIZOMS8R25RaroWfV/view?usp=sharing

<Crash / Freeze> Ammo

Most helpful comment

Introduced by https://github.com/CleverRaven/Cataclysm-DDA/pull/45327

diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp
index c556bd4e49..8af89dba3d 100644
--- a/src/vehicle_use.cpp
+++ b/src/vehicle_use.cpp
@@ -2226,7 +2226,7 @@ void vehicle::interact_with( const vpart_position &vp )
             std::vector<item_location> targets;
             if( opt ) {
                 targets.emplace_back( turret.base() );
-                targets.push_back( std::move( opt.ammo ) );
+                targets.push_back( opt.ammo );
                 player_character.assign_activity( player_activity( reload_activity_actor( opt.moves(), opt.qty(),
                                                   targets ) ) );
             }

seems to fix it. Another option is to cache opt.moves() before std::moveing.

The crash on reloading a non-vehicle gun is a different error from the same PR AFAICT.

All 13 comments

Just had this when trying to reload an M2 on an APC.

It also seems to happen with any 308 gun, and/or any 308 ammo

Also getting a segmentation fault here when reloading a vehicle-mounted M249
image

Introduced by https://github.com/CleverRaven/Cataclysm-DDA/pull/45327

diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp
index c556bd4e49..8af89dba3d 100644
--- a/src/vehicle_use.cpp
+++ b/src/vehicle_use.cpp
@@ -2226,7 +2226,7 @@ void vehicle::interact_with( const vpart_position &vp )
             std::vector<item_location> targets;
             if( opt ) {
                 targets.emplace_back( turret.base() );
-                targets.push_back( std::move( opt.ammo ) );
+                targets.push_back( opt.ammo );
                 player_character.assign_activity( player_activity( reload_activity_actor( opt.moves(), opt.qty(),
                                                   targets ) ) );
             }

seems to fix it. Another option is to cache opt.moves() before std::moveing.

The crash on reloading a non-vehicle gun is a different error from the same PR AFAICT.

Got the same problem when reloading crossbow.
I would confirm that all the issues come from #45327 and from std::move. I'll add some comments into PR to clarify the details.

Introduced by #45327

diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp
index c556bd4e49..8af89dba3d 100644
--- a/src/vehicle_use.cpp
+++ b/src/vehicle_use.cpp
@@ -2226,7 +2226,7 @@ void vehicle::interact_with( const vpart_position &vp )
             std::vector<item_location> targets;
             if( opt ) {
                 targets.emplace_back( turret.base() );
-                targets.push_back( std::move( opt.ammo ) );
+                targets.push_back( opt.ammo );
                 player_character.assign_activity( player_activity( reload_activity_actor( opt.moves(), opt.qty(),
                                                   targets ) ) );
             }

seems to fix it. Another option is to cache opt.moves() before std::moveing.

The crash on reloading a non-vehicle gun is a different error from the same PR AFAICT.

Is there any way I can apply this patch to my game, without having to wait for the next build with the fix?

Clone the game, save the patch to a fix.patch file, run git apply fix.patch, compile the game.

Clone the game, save the patch to a fix.patch file, run git apply fix.patch, compile the game.

Really sorry, I'm not sure if this is the place to do ask this, but:

I have cloned the repo, installed Git and Vcpkg, and all of the packages.
But when I try to compile I get the following build errors, and cannot manage to solve them:

error : The Vcpkg manifest was enabled, but we couldn't find a manifest file (vcpkg.json) in any directories above E:\Github\Cataclysm-DDA\msvc-full-features. Please add a manifest, disable manifests in your properties page, or pass /p:VcpkgEnableManifest=false.

(Following the instructions here still leaves the below issue + I feel like disabling the manifest is not the solution?)

E:\Github\Cataclysm-DDA\msvc-full-features\stdafx.h(80,16): fatal error C1083: Cannot open include file: 'SDL2/SDL.h': No such file or directory

I have tried locating the files to no avail, and I have tried changing some settings as recommended by the great internet, but nothing seems to be working.

Any ideas?

Sorry, I am not at all familiar with vs or vcpkg, I can't help there.

between this and #44672 all turrets are broken

was having this crash my game too, and was crashing after reloading guns that weren't mounted. couldn't replicate on a new character.

Seeing as I'm partially responsible I will have a go at fixing this from the ammo belt/non mounted weapons side. Just gotta find some time for this :)

This bug relates to all kinds of reloading activities, so guns, turrets, crossbows, all this stuff is broken right now.

Was this page helpful?
0 / 5 - 0 ratings