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

Combat Knife bayonet crashing #30676

Closed
killsode opened this issue May 20, 2019 · 14 comments · Fixed by #35132
Closed

Combat Knife bayonet crashing #30676

killsode opened this issue May 20, 2019 · 14 comments · Fixed by #35132
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons (S2 - Confirmed) Bug that's been confirmed to exist
Milestone

Comments

@killsode
Copy link

killsode commented May 20, 2019

Describe the bug

Switching firing modes with a gun equipped with a combat knife bayonet causes a crash.

Steps To Reproduce

  1. Equip a loaded gun with a combat knife bayonet
  2. Enter the firing menu
  3. Cycle through all the firing modes

Expected behavior

Seems like the game is attempting to change to a "combat knife" firing mode that just doesn't work

Versions and configuration

  • OS: Windows [64-bit]
  • Game Version: 0.D-3197-gda3edc5
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Craftable Gun Pack [craftgp],
    DeadLeaves' Fictional Guns [FIC_Weapons],
    Extended Realistic Guns [realguns],
    Garden Pots [growable-pots],
    Makeshift Items Mod [makeshift],
    Medieval and Historic Content [Medieval_Stuff],
    More Survival Tools [More_Survival_Tools],
    Mythological Replicas [nw_pack],
    Modular Turrets [modular_turrets],
    Salvaged Robots [Salvaged_Robots],
    DinoMod [DinoMod],
    Alternative Map Key [alt_map_key],
    Hydroponics [hydroponics],
    Mutant NPCs [mutant_npcs],
    Boats [boats],
    Folding Parts pack [deoxymod],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    No Fungal Monsters [No_Fungi],
    Classes and Scenarios Mod [more_classes_scenarios],
    Classic Roguelike Classes [RL_Classes],
    Safe Autodoc [safeautodoc],
    StatsThroughSkills [StatsThroughSkills]
    ]

Additional context

first time reporting a bug ^.^

Crash log

crash.log

@Night-Pryanik Night-Pryanik added (S1 - Need confirmation) Report waiting on confirmation of reproducibility <Crash / Freeze> Fatal bug that results in hangs or crashes. Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons labels May 20, 2019
@EternalLaughter
Copy link

EternalLaughter commented May 23, 2019

Similar issue here, tough on mode switch, i first get a pop up window saying:

MinGW Runtime Assertion

Assertion failed!

Program: C:\Games\CDDA\cataclysm-tiles.exe
File: src/optional.h, Line 45
Expression: full

Abort Retry Ignore

Then on retry or abort, (you cannot ignore, window just comes instantly back up) i get the crash log (attached)

  • OS: Windows [64-bit]
  • Game Version: 0.D-3311-g5147b3c
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Icecoon's Arsenal [ew_pack],
    Makeshift Items Mod [makeshift],
    Medieval and Historic Content [Medieval_Stuff],
    More Survival Tools [More_Survival_Tools],
    Mutant NPCs [mutant_npcs],
    Folding Parts pack [deoxymod],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    Disable Religious Texts [no_religious_Texts],
    Crazy Cataclysm [crazy_cataclysm]
    ]

Tested on a fresh world\game\character with spawning in the items and then targeting nearby enemy and attempting to change firing mode.

Shouldn't matter but, specifically i spawned an AK47, magazine and ammo for it, loaded it in, then attaching the combat knife.
Tried attaching the save file, which as far as i understand is the world file. (only one char in there, ready to test with mentioned equips)

crash.log

Alt mapkey.zip

@neitsa
Copy link
Contributor

neitsa commented May 25, 2019

Can't reproduce anymore on official release 0.D-3479-g3233182 (or debug version from master).

  • Load save file from @EternalHunter777
  • Cycle through firing mode with SHIFT + f

Default (after loading save):

image

  • 1st cycle (F):
    image

  • 2nd cycle (F):
    image

  • 3rd cycle (F):
    image

Note: as a side note, and unless I'm mistaken, there's no more a "cycle firing mode" menu in the firing menu (f).

@EternalLaughter
Copy link

@neitsa You are correct in that using shift-f to choose mode between SA\FA\Combat knife bayonet does not crash the game.

However, entering the targeting UI, by just hitting "f", and THEN changing fire-mode by just hitting "s" it will crash when it should cycle to combat knife mode.
The cycle as i call it, is just the eternal changing between fire modes, whatever they may be.
For this weapon it is Semi Auto - Bayonet - Full Auto.

The fault here was with me not describing the exact reproducible way, as i believed the OP had done so.

@neitsa
Copy link
Contributor

neitsa commented May 25, 2019

Oh ok, thanks for the precision! No problem, I wasn't sure how to cycle in the firing menu since I never use it from there.

I'll test exactly as you mentioned. Thanks a lot!

@neitsa
Copy link
Contributor

neitsa commented May 26, 2019

Got a repro (and this time I could see the [s] switch firing mode in the firing menu...)

It's an assert:

const T &get() const {
assert( full );
return data;
}

full is false which triggers the assert and data is completely uninitialized.

The stack trace:

 	ucrtbased.dll!common_assert_to_message_box<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 388	C++
 	ucrtbased.dll!common_assert<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 424	C++
 	ucrtbased.dll!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 444	C++
>	Cataclysm-App-Debug-x64.exe!cata::optional<islot_gun>::get() Line 45	C++
 	Cataclysm-App-Debug-x64.exe!cata::optional<islot_gun>::operator->() Line 104	C++
 	Cataclysm-App-Debug-x64.exe!time_to_fire(const Character & p, const itype & firing) Line 2047	C++
 	Cataclysm-App-Debug-x64.exe!print_ranged_chance(const player & p, const catacurses::window & w, int line_number, target_mode mode, input_context & ctxt, const item & ranged_weapon, const dispersion_sources & dispersion, const std::vector<confidence_rating,std::allocator<confidence_rating> > & confidence_config, double range, double target_size, int recoil) Line 895	C++
 	Cataclysm-App-Debug-x64.exe!print_aim(const player & p, const catacurses::window & w, int line_number, input_context & ctxt, item * weapon, const double target_size, const tripoint & pos, double predicted_recoil) Line 967	C++
 	Cataclysm-App-Debug-x64.exe!target_handler::target_ui(player & pc, target_mode mode, item * relevant, int range, const itype * ammo, const std::function<itype const * __cdecl(item *)> & on_mode_change, const std::function<itype const * __cdecl(item *)> & on_ammo_change) Line 1387	C++
 	Cataclysm-App-Debug-x64.exe!target_handler::target_ui(player & pc, const targeting_data & args) Line 1028	C++
 	Cataclysm-App-Debug-x64.exe!game::plfire() Line 7939	C++
 	Cataclysm-App-Debug-x64.exe!game::plfire(item & weapon, int bp_cost) Line 7993	C++
 	Cataclysm-App-Debug-x64.exe!fire() Line 1205	C++
 	Cataclysm-App-Debug-x64.exe!game::handle_action() Line 1827	C++
 	Cataclysm-App-Debug-x64.exe!game::do_turn() Line 1422	C++
 	Cataclysm-App-Debug-x64.exe!SDL_main(int argc, char * * argv) Line 689	C++
 	Cataclysm-App-Debug-x64.exe!main_getcmdline(...) Line 177	C
 	[External Code]

I'll try to understand what's happening.

@ifreund
Copy link
Contributor

ifreund commented May 26, 2019

From just reading the stack trace I'd guess that a combat bayonet isn't a gun and therefore islot_gun is a cata::nullopt. The optional is however dereferenced when cycling through firing modes which expects everything to be a gun, which causes the assert to fail.

Just realized that's probably pretty obvious but posting anyways cause why not. ¯\_(ツ)_/¯

@neitsa
Copy link
Contributor

neitsa commented May 26, 2019

Not at all @ifreund, it wasn't obvious to me :| Thanks a lot for posting this otherwise I'd still be digging!

I'm not really sure how to fix this though... Would removing the bayonet / combat knife from the firing modes would be an acceptable patch?

@ifreund
Copy link
Contributor

ifreund commented May 26, 2019

Yeah I think that cycling fire modes from the target ui should skip melee firing modes, since those can't be used from that ui afaik. The should still be part of firing modes outside of that ui though I think.

@neitsa
Copy link
Contributor

neitsa commented May 26, 2019

Added a fix, it seems to correctly handle the problem. (bugged fix).

@EternalLaughter
Copy link

Great! 💯

@mlangsdorf
Copy link
Contributor

intermittent heisenbug, apparently caused by bayonet style weapons intermittently returning true from item::is_gun() and then crashing when trying to actually access item::type->gun because they're not a gun.

@ymber ymber added this to the 0.E milestone Oct 27, 2019
@esotericist
Copy link
Contributor

Should be fixed by #35102.

@ymber
Copy link
Member

ymber commented Oct 28, 2019

This issue is still reproducible in current master.

@ymber ymber reopened this Oct 28, 2019
@LetterShapedGlyphs
Copy link
Contributor

LetterShapedGlyphs commented Oct 28, 2019

The issue stems from the fact that bayonets straddle a very weird line between islot_mod and islot_gunmod and many functions involving using a firearm alternate between checking the two as if they were the same (or always guaranteed to be together) which they currently are not.

That was completely wrong, but I found the real problem anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants