Page MenuHomeFeedback Tracker

memory access violation when deleting hashmap key
Closed, ResolvedPublic

Description

Arma experiences a seg fault when deleting a key from a hashmap, with value of another hashmap, that hash has a control in the nested hashmap. Weird right.

A3A_shoppingCart

  • "key" - nestedHashmap
    • ["_price", _price];
    • ["_control", _itemControlsGroup];
    • ["_controlAmount", _amountText];
    • ["_controlCost", _totalCost];

Deleting this key doesn't cause a crash out right by making a reference A3A_shoppingCart seems to crash arma after deleting that key.

if(_className in A3A_shoppingCart) exitWith 
{
	private _map =  A3A_shoppingCart get _className;
	private _amount = _map getOrDefault ["_amount", 0];
	_amount = _amount + _amountAdd;

	// delete the item from the cart
	if(_amount <= 0) exitWith {
		_itemControlsGroup = _map getOrDefault ["_control", -1];
		A3A_shoppingCart deleteAt _className;

		ctrlDelete _itemControlsGroup;
		call A3A_fnc_updateCartNumber;
	};

	private _amountText = _map getOrDefault ["_controlAmount", -1];
	_amountText ctrlSetStructuredText parseText (format ["<t size='0.65' align='left' valign='middle' align='center' shadow='2'>%1</t>", _amount]);
	_amountText ctrlCommit 0;
	
	private _totalCost = _map getOrDefault ["_controlCost", -1];
	private _weaponPrice = _map getOrDefault ["_price", -1];
	_totalCost ctrlSetStructuredText parseText (format ["<t size='0.65' align='left' valign='middle' color='#085F16' shadow='2'>€ %1</t>", _weaponPrice * _amount]);
	_totalCost ctrlCommit 0;



	_map set ["_amount", _amount];
	A3A_shoppingCart set [_className, _map];
	
};

calling A3A_fnc_updateCartNumber which makes reference to A3A_shoppingCart, crashes arma everytime.

  • A3A_fnc_updateCartNumber
#include "..\..\dialogues\ids.inc"
#include "..\..\script_component.hpp"
#include "..\..\dialogues\defines.hpp"

private _display = findDisplay A3A_IDD_GUN_SHOP;
private _control = _display displayCtrl A3A_IDC_GUN_SHOP_CART_NUMBER;


private _count = count A3A_shoppingCart;

_control ctrlSetText format ["%1", _count];
_control ctrlSetFade 0;
_control ctrlCommit 0;

if !(ctrlShown _control) then {_control ctrlShow true};

Details

Severity
Crash
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Download test mission.
Follow video and have a seg fault.

Additional Information

Event Timeline

killerswin2 updated the task description. (Show Details)

this can be closed

dedmen closed this task as Resolved.May 1 2023, 5:33 PM
dedmen claimed this task.