Recursion limit error when ExitApp executes. Topic is solved

Report problems with documented functionality
Makin_Me_Crazy-ier
Posts: 17
Joined: 20 Jul 2023, 17:15

Recursion limit error when ExitApp executes.

13 Sep 2023, 12:24

The following code was posted two weeks ago and has received no comment with respect to possible coding error or verification of the issue further described in the title topic.
I have since tested the code with the current release version and find the issue remains evident. I have tested code that merely makes By-Refrence calls through multiple function levels and find no issue. Moreover, I have tested code that loops on a dll call containing a By-Reference variable and the issue is not evident.

I have found the issue to be present now with two examples where the By-Refrence variable is passed to/from a function containing a Dll. In both cases the variable name passed to the function is the same as the variable name passed to/from the dll. The first example included in the subject posting was a serial port read file dll which required many more moving parts to demonstrate. The following code is self contained and clearly demonstrates the issue.

Code: Select all

;This test was run on AHK Version 2.0.3 and as of 9/8/2023 version 2.0.7 and as of 9/12/2023 version 2.0.8
; The test exhibits the warning message 'Critical Error: Function recursion limit exceeded.'
; when allowed to complete and 'ExitApp' function is executed.
; If the Test_Screensaver() function is changed to use the 'intermediate_result' variable this issue is not encountered.
#Requires AutoHotkey v2+
#SingleInstance force
Persistent
SPI_GETSCREENSAVERRUNNING := 0x0072
MsgBox "Ckick OK to proceed with this test. `nTest will pause 5 seconds and beep`nThen pause 5 seconds, longer beep and ExitApp`n`n Press ctrl F1 to abort test`nAutoHotKey version " A_AhkVersion
global Beep_Count:=0
screen_saver_active:=0

^F1::               ;Ctrl F1 hotkey SCRAM
{
  SetTimer Time_check,0
  MsgBox("Screen Saver Test will now exit")
  ExitApp
}
SetTimer Time_check,5000		;5 sec. beep interval

loop {
	test_result:=Test_Screensaver(&screen_saver_active)
	if (test_result = 0) {
		break		;Dll failed
	}
}

Test_Screensaver(&screen_saver_active) {
	intermediate_result:=0
	Dll_result := DllCall( "user32.dll\SystemParametersInfo"	; Working test for active screensaver
	, "uint", SPI_GETSCREENSAVERRUNNING
	, "uint", 0
	, "uint*", &screen_saver_active							; this is the problem argument
	;, "uint*", &intermediate_result						; This is the work-arround argument
	, "uint", 0 )
	;screen_saver_active:=intermediate_result
	if (Dll_result =0) {	; result =0 DLL failed
		msgbox "SPI_GETSCREENSAVERRUNNING Dll failed `n" GetErrorString(A_LastError) , "Cootie Catcher Test -- Line " A_LineNumber
	}
	return Dll_result
}

Time_check() {
global Beep_Count
	Beep_Count:=Beep_Count+1
	if (Beep_Count=2 ) {
		Beep_Count:=0
		SoundBeep 1000,1000
		SetTimer Time_check,0
		ExitApp
	}
	else SoundBeep 700,300
return
}

GetErrorString(Errornumber)             ;Usually set to A_LastError
  {
	VarSetStrCapacity(&ErrorString, 1024)		;String to hold the error-message.
	DllCall("FormatMessage"         ;FORMAT_MESSAGE_FROM_SYSTEM:
            , "UINT",  0x00001000	;The function should search the system message-table resource(s) for the requested message.
			, "UINT", 0             ;A handle to the module that contains the message table to search.
			, "UINT", Errornumber
			, "UINT", 0				;Language-ID is automatically retreived
			, "Str" , ErrorString
			, "UINT", 1024			;Buffer-Length
			, "str" , ""
            )
	ErrorString := StrReplace(ErrorString, "`r`n", A_Space)		;Replaces newlines by A_Space for one line-output
	return ErrorString
  }
[Mod edit: Removed empty additional codebox.]
Makin_Me_Crazy-ier
Posts: 17
Joined: 20 Jul 2023, 17:15

Re: Recursion limit error when ExitApp executes.

17 Sep 2023, 16:32

Many thanks for fixing this. Maybe a little less crazy now and AHK V2 takes another step to greater stability.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 10 guests