crash with no error message

Ask for help, how to use AHK_H, etc.
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

crash with no error message

05 Aug 2019, 23:25

Hey guys. So I ran into another problem...

I'm getting a crash to desktop with no error message. I've narrowed the problem code to what you see below. More specifically, this code and the code it executes is 100% where the issue lies:

Code: Select all

this.m_Keys.Push(CriticalObject(new Key("LButton", KeybindType.Targeted, "$LButton")))
this.m_Keys.Push(CriticalObject(new Key("RButton", KeybindType.Targeted, "$RButton")))
this.m_Keys.Push(CriticalObject(new Key("q", KeybindType.Targeted, "$q")))
this.m_Keys.Push(CriticalObject(new Key("w", KeybindType.Targeted, "$w")))
this.m_Keys.Push(CriticalObject(new Key("e", KeybindType.Targeted, "$e")))
this.m_Keys.Push(CriticalObject(new Key("r", KeybindType.Targeted, "$r")))
local i, _key
For i, _key in this.m_Keys
{
	AHKThread("
	(
		#Include Input\KeyPressThread.ahk
	)", &this.m_Keys[i] "")
}
Key class

Code: Select all

class Key
{
	__New(p_KeybindString, p_KeybindType, p_Hotkey)
	{
		global

		this.m_State 	 	:= False
		this.m_PrevState	:= this.m_State

		this.m_Keybind := IniReader.ParseKeybind(p_KeybindString)
		this.m_Keybind.Type := p_KeybindType

		this.m_Hotkey := p_Hotkey
	}

	State[] {
		get {
			return this.m_State
		}
		set {
			return this.m_State := value
		}
	}
	PrevState[] {
		get {
			return this.m_PrevState
		}
		set {
			return this.m_PrevState := value
		}
	}

	Keybind[] {
		get {
			return this.m_Keybind
		}
	}

	Hotkey[] {
		get {
			return this.m_Hotkey
		}
	}
}
KeyPressThread.ahk

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
;#SingleInstance Force
#Persistent  ; Keep this script running until the user explicitly exits it.

;#MaxHotkeysPerInterval 99000000
;#HotkeyInterval 99000000
;#MaxThreads 255

#KeyHistory 0

ListLines Off

Process, Priority, , A
SetBatchLines, -1

_critObj := CriticalObject(A_Args[1])

_boundFunction := Func("PressKeybind").Bind(_critObj)
Hotkey, % _critObj.Hotkey, % _boundFunction

return

PressKeybind(p_Key)
{
	if (p_Key.State = True)
			Exit

	p_Key.PrevState := p_Key.State
	p_Key.State := True
}

;~$F12::
;	ExitApp
;return

However, I don't really know enough about threads and how they work in AHK.
The only reason why I put these Hotkeys into their own thread is because when too many hotkeys in the array fired off some became "stuck" (The 'Up' hotkey didn't fire after physically releasing the key so the key was still considered held by the script).
So to solve that issue I put them into their own thread. Now the programs crashes to desktop though, so I'd consider that a step in the wrong direction...
If someone knows why a hotkey might not fire off or what's wrong with the current threaded solution that would be much appreciated.

As a heads up, I don't access 'this.m_Keys' ever again. That part where I would is currently commented out, but the issue persists.

Also, here is the error in the event viewer:
error.png
error.png (35.94 KiB) Viewed 3644 times
[Mod edit: Topic name added]
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: crash with no error message

06 Aug 2019, 00:27

STATUS_HEAP_CORRUPTION
this line looks funny )", &this.m_Keys ""). i cant exactly recall if it was true, but u cant fetch the address of an object nested multiple times directly like that without having to do reassignments first
try )", &_key ""), assigned by the forloop
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

Re: crash with no error message

06 Aug 2019, 19:32

Unfortunately it still crashes even with this change.

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 18 guests