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

Reproducible Seg Fault when turning on Heavy-Duty Flashlight #78580

Open
TRScheel opened this issue Dec 15, 2024 · 2 comments
Open

Reproducible Seg Fault when turning on Heavy-Duty Flashlight #78580

TRScheel opened this issue Dec 15, 2024 · 2 comments
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility

Comments

@TRScheel
Copy link
Contributor

Describe the bug

I attached the flashlight to the car and turned it on. Immediately caused a seg fault. It is reproducible.

Attach save file

Twain Harte-trimmed.tar.gz

Steps to reproduce

  1. Load the attached save
  2. Press a to use an item
  3. Select the heavy-duty flashlight that is being wielded
  4. Turn it on

Expected behavior

It shouldn't seg fault

Screenshots

image

image

image

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.5131 (22H2)
  • Game Version: 2a8e243 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    Magiclysm [magiclysm],
    Mythical Martial Arts [MMA],
    Translate Complex Dialogue [translate_dialogue]
    ]

Additional context

config.zip

@TRScheel TRScheel added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Dec 15, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Dec 15, 2024

Confirmed.

- OS: Windows
    - OS Version: 10.0.19043 (21H1)
- Game Version: 7acb286 [64-bit]
- Graphics Version: Tiles
- Game Language: Русский <color_dark_gray>(91,7%)</color> [ru]
- Mods loaded: [
    Тёмные Дни Впереди [dda],
    Отключить потребности у НПС [no_npc_food],
    Портальные штормы игнорируют НПС [personal_portal_storms],
    Медленный рост фунгалоидов [no_fungal_growth]
]

You need a flashlight without a battery to reproduce it. Plug it into the car (or a placed battery) and try to turn it on.

It might be important. If you remove the string:

"charges_per_use": 1,

Then turning on the flashlight does not cause a crash.

@TRScheel Alternative. Insert a battery into the flashlight, then it will turn on without error.

@marilynias
Copy link
Contributor

hmm, the

"id": "electric_blanket",

work the same way (with charges_per_use) and it doesn't crash. If im not missing anything, everything should be the same.
0x5c0,360,682,c20 src/item.cpp:12,149 item::getlight_emit() const
seems like lighting requires battery charges.

TRScheel added a commit to TRScheel/Cataclysm-DDA that referenced this issue Dec 17, 2024
There was a segfault occuring on
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L12277 when
turning on a heavy-duty flashlight while it is simultaneously connected to a
power source (ie. a vehicle) and does not have a battery.

Added:

-   a short circuit check for ammo to address this issue in the future in
    case there are any other edge cases where this occurs.
-   a check for a linked power source so the light source uses the
    power source's linked power when determining the illumination value.

Fixes CleverRaven#78580

Note: I used https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L14177
as a reference for the linked power check above. This means the two power checks are extremely similar
and it makes me believe that it would be beneficial to have a function such as
`has_link_power` that returns a boolean (true for has power, false otherwise). My only
hesitation is that I do not know where else that sort of power check is done and what the complete
scope of the checks against `charge_rate` / `charge_interval` are for.
TRScheel added a commit to TRScheel/Cataclysm-DDA that referenced this issue Dec 18, 2024
There was a segfault occuring on
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L12277 when
turning on a heavy-duty flashlight while it is simultaneously connected to a
power source (ie. a vehicle) and does not have a battery.

Added:

-   a short circuit check for ammo to address this issue in the future in
    case there are any other edge cases where this occurs.
-   a check for a linked power source so the light source uses the
    power source's linked power when determining the illumination value.

Fixes CleverRaven#78580

Note: I used https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L14177
as a reference for the linked power check above. This means the two power checks are extremely similar
and it makes me believe that it would be beneficial to have a function such as
`has_link_power` that returns a boolean (true for has power, false otherwise). My only
hesitation is that I do not know where else that sort of power check is done and what the complete
scope of the checks against `charge_rate` / `charge_interval` are for.
TRScheel added a commit to TRScheel/Cataclysm-DDA that referenced this issue Dec 18, 2024
There was a segfault occuring on
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L12277 when
turning on a heavy-duty flashlight while it is simultaneously connected to a
power source (ie. a vehicle) and does not have a battery.

Added:

-   a short circuit check for ammo to address this issue in the future in
    case there are any other edge cases where this occurs.
-   a check for a linked power source so the light source uses the
    power source's linked power when determining the illumination value.

Fixes CleverRaven#78580

Note: I used https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L14177
as a reference for the linked power check above. This means the two power checks are extremely similar
and it makes me believe that it would be beneficial to have a function such as
`has_link_power` that returns a boolean (true for has power, false otherwise). My only
hesitation is that I do not know where else that sort of power check is done and what the complete
scope of the checks against `charge_rate` / `charge_interval` are for.
TRScheel added a commit to TRScheel/Cataclysm-DDA that referenced this issue Dec 18, 2024
There was a segfault occuring on
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L12277 when
turning on a heavy-duty flashlight while it is simultaneously connected to a
power source (ie. a vehicle) and does not have a battery.

Added:

-   a short circuit check for ammo to address this issue in the future in
    case there are any other edge cases where this occurs.
-   a check for a linked power source so the light source uses the
    power source's linked power when determining the illumination value.

Fixes CleverRaven#78580

Note: I used https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L14177
as a reference for the linked power check above. This means the two power checks are extremely similar
and it makes me believe that it would be beneficial to have a function such as
`has_link_power` that returns a boolean (true for has power, false otherwise). My only
hesitation is that I do not know where else that sort of power check is done and what the complete
scope of the checks against `charge_rate` / `charge_interval` are for.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility
Projects
None yet
Development

No branches or pull requests

3 participants