CleverRaven / Cataclysm-DDA

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

Plugging a smart lamp into a grid/vehicle and turning it on causes segfault #76245

Closed CoroNaut closed 3 weeks ago

CoroNaut commented 3 weeks ago

Describe the bug

As title, turning on a smart lamp while it is plugged into a grid or vehicle will cause segfault

Attach save file

TESTING-trimmed.tar.gz

Steps to reproduce

  1. Get smart lamp
  2. Get a vehicle or grid with power
  3. Plug in the smart lamp
  4. Turn on smart lamp
  5. Segfault fun

Expected behavior

No segfault when turning on a lamp. Lamp deserves to be lit! LAMP!

Screenshots

No response

Versions and configuration

Additional context

crash.log

PatrikLundell commented 3 weeks ago

/Confirmed

It blows up in item.cpp operation item::update_link_traits when trying to use get_use("link_up")->get_actor_ptr() when get_use returned a null pointer. The item in question is the turned on smart lamp.

The problem is caused by the operation being called with the turned on smart lamp, while the "link_up" action is defined on the turn off version. Hacking the JSON to add "link_up" to the turned on version causes the game to say the lamp is turned on when turned on.

Electric carver has the action on both the off and on versions. Same for:

Given the precedents, it seems the action should be defined in all versions of the item. PR upcoming...