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

item::gun_range dereferences null pointer #32298

Closed
ymber opened this issue Jul 10, 2019 · 0 comments · Fixed by #32316
Closed

item::gun_range dereferences null pointer #32298

ymber opened this issue Jul 10, 2019 · 0 comments · Fixed by #32316
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

Comments

@ymber
Copy link
Member

ymber commented Jul 10, 2019

Describe the bug

The game crashes when item::gun_range tries to dereference a null pointer. When that method is called from an object that contains no ammo items and has a gunmod that defines ammo_modifier it will end up trying to dereference the ammo islot of the null item.

Steps To Reproduce

  1. Debug in one of the old caliber conversion kits and a gun
  2. Install the conversion kit on the gun
  3. Go to your character's inventory and select the gun

Expected behavior

Normal inventory function without crashes.

Versions and configuration

  • OS: Arch Linux x86_64 kernel 5.1.16-arch1-1-ARCH
  • Game Version: 0.D-5504-g4f3fee78cf

Additional context

The program has crashed.
See the log file for a stack trace.
CRASH LOG FILE: ./config/crash.log
VERSION: 0.D-5504-g4f3fee78cf
TYPE: Signal
MESSAGE: SIGABRT: Abnormal termination
STACK TRACE:

	./cataclysm-tiles(_Z21debug_write_backtraceRSo+0x39) [0x55c98f587059]
	./cataclysm-tiles(+0x133e0b3) [0x55c98f5690b3]
	./cataclysm-tiles(+0x133de58) [0x55c98f568e58]
	/usr/lib/libc.so.6(+0x3a7e0) [0x7f8bb71407e0]
	/usr/lib/libc.so.6(gsignal+0x145) [0x7f8bb7140755]
	/usr/lib/libc.so.6(abort+0x125) [0x7f8bb712b851]
	/usr/lib/libc.so.6(+0x25727) [0x7f8bb712b727]
	/usr/lib/libc.so.6(+0x33026) [0x7f8bb7139026]
	./cataclysm-tiles(+0x11b4f0d) [0x55c98f3dff0d]
	./cataclysm-tiles(_ZNK4cata8optionalI10islot_ammoEptEv+0x6) [0x55c98f417096]
	./cataclysm-tiles(_ZNK4item9gun_rangeEb+0x104) [0x55c98f7f9854]
	./cataclysm-tiles(_ZNK4item9gun_rangeEPK6player+0x2c) [0x55c98f7ed40c]
	./cataclysm-tiles(_ZNK4item4infoB5cxx11ERSt6vectorI8iteminfoSaIS1_EEPK14iteminfo_queryi+0x48f9) [0x55c98f7d8bf9]
	./cataclysm-tiles(_ZNK4item4infoB5cxx11EbRSt6vectorI8iteminfoSaIS1_EEi+0x26) [0x55c98f7d42f6]
	./cataclysm-tiles(_ZNK4item4infoB5cxx11EbRSt6vectorI8iteminfoSaIS1_EE+0xf) [0x55c98f7d42bf]
	./cataclysm-tiles(_ZN4game19inventory_item_menuEiiiNS_27inventory_item_menu_positonE+0x8af) [0x55c98f69443f]
	./cataclysm-tiles(_ZN10game_menus3inv6commonER6avatar+0x1b5) [0x55c98f70d235]
	./cataclysm-tiles(_ZN4game13handle_actionEv+0xf04) [0x55c98f72e6f4]
	./cataclysm-tiles(_ZN4game7do_turnEv+0x52d) [0x55c98f68bb5d]
	./cataclysm-tiles(main+0xbc0) [0x55c98f984150]

	Attempting to repeat stack trace using debug symbols...
	debug_write_backtrace(std::ostream&)
	.../src/debug.cpp:620
	log_crash(char const*, char const*)
	crash.cpp:?
	signal_handler(int)
	.../src/crash.cpp:292
	__restore_rt
	sigaction.c:?
	__GI_raise
	:?
	__GI_abort
	:?
	_nl_load_domain.cold
	loadmsgcat.c:?
	__GI___assert_fail
	:?
	cata::optional<islot_ammo>::get() const
	??:?
	cata::optional<islot_ammo>::operator->() const
	.../src/optional.h:105
	item::gun_range(bool) const
	.../src/item.cpp:5770
	item::gun_range(player const*) const
	.../src/item.cpp:5777
	item::info[abi:cxx11](std::vector<iteminfo, std::allocator<iteminfo> >&, iteminfo_query const*, int) const
	.../src/item.cpp:1501
	item::info[abi:cxx11](bool, std::vector<iteminfo, std::allocator<iteminfo> >&, int) const
	.../src/item.cpp:876
	item::info[abi:cxx11](bool, std::vector<iteminfo, std::allocator<iteminfo> >&) const
	.../src/item.cpp:871
	game::inventory_item_menu(int, int, int, game::inventory_item_menu_positon)
	??:?
	game_menus::inv::common(avatar&)
	.../src/game_inventory.cpp:202
	game::handle_action()
	.../src/handle_action.cpp:1795
	game::do_turn()
	.../src/game.cpp:1428
	main
	.../src/main.cpp:688
@ZhilkinSerg ZhilkinSerg added (S2 - Confirmed) Bug that's been confirmed to exist <Crash / Freeze> Fatal bug that results in hangs or crashes. Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons labels Jul 11, 2019
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.

2 participants