Cataclysm-dda: Crash when attempting to fire compound bow w/ wooden broadhead arrows

Created on 13 Jun 2019  路  4Comments  路  Source: CleverRaven/Cataclysm-DDA

Describe the bug

Attempting to fire causes a crash.

Steps To Reproduce

wield bow, press 'f'

Versions and configuration

  • OS: Linux

    • OS Version: Ubuntu 18.04 in Docker (running on Ubuntu 18.04 host)

  • Game Version: 0.D-4254-g4259f65 [64-bit]
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    C.R.I.T Expansion Mod [crt_expansion],
    Medieval and Historic Content [Medieval_Stuff],
    More Survival Tools [More_Survival_Tools],
    Makeshift Items Mod [makeshift],
    DinoMod [DinoMod],
    Modular Turrets [modular_turrets],
    Salvaged Robots [Salvaged_Robots],
    Alternative Map Key [alt_map_key],
    Mutant NPCs [mutant_npcs],
    Mythical Martial Arts [MMA],
    Beta National Guard Camp [national_guard_camp],
    More Locations [more_locations],
    Fuji's More Buildings [FujiStruct],
    Folding Parts pack [deoxymod],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    Simplified Nutrition [novitamins]
    ]

Additional context

crash.log
debug.log
cataclysm-save.tar.gz

<Crash / Freeze> Ranged

Most helpful comment

In avatar_action::fire():

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/avatar_action.cpp#L701-L709

On the else if line, the code starts by calling weapon.ammo_data():

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5878-L5902

The is_gun() condition is true, but the loop fails at finding a valid item.

    auto mods = is_gun() ? gunmods() : toolmods();
    for( const auto e : mods ) {
        if( !e->type->mod->ammo_modifier.empty() &&
            item_controller->has_template( e->ammo_current() ) ) {
            return item_controller->find_template( e->ammo_current() );
        }

The code ends by returning curammo:

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5901

But curammo is null:

> ? weapon.curammo
0x0000000000000000 <NULL>

So it's obviously crashing on a null pointer while dereferencing ammo here (in avatar_action::fire):

weapon.ammo_data()->ammo

All 4 comments

I'm having the same on latest game compiled from source VERSION: 0.D-4506-ge5ea394
This happens with bow, but also with a crossbow which I forgot to 'r'eload...(when it shows as crossbow 0/1)

I did a little digging and this started with build 9143 per http://gorgon.narc.ro:8080/job/Cataclysm-Matrix/changes, which includes 64516a6b95b32e522ed6732b740a5cf178664d57

In avatar_action::fire():

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/avatar_action.cpp#L701-L709

On the else if line, the code starts by calling weapon.ammo_data():

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5878-L5902

The is_gun() condition is true, but the loop fails at finding a valid item.

    auto mods = is_gun() ? gunmods() : toolmods();
    for( const auto e : mods ) {
        if( !e->type->mod->ammo_modifier.empty() &&
            item_controller->has_template( e->ammo_current() ) ) {
            return item_controller->find_template( e->ammo_current() );
        }

The code ends by returning curammo:

https://github.com/CleverRaven/Cataclysm-DDA/blob/e7ca42c3cecf22bb667b57fd657e2292e54a2f7c/src/item.cpp#L5901

But curammo is null:

> ? weapon.curammo
0x0000000000000000 <NULL>

So it's obviously crashing on a null pointer while dereferencing ammo here (in avatar_action::fire):

weapon.ammo_data()->ammo

Crashing with rifles as well, upon attempting to fire while the gun is _not loaded_. Happens 100% of the time.

Was this page helpful?
0 / 5 - 0 ratings