Page 1 of 1

Fixed - Crash in AHK 32bit

Posted: 31 Aug 2014, 18:42
by TAC109
This code crashes AHK 32bit. (Haven't tested on others.)

Code: Select all

Gui, Add, Edit, y+10 W710  vExResult ReadOnly
Gui Show
params:={}, params[1]:="-"
GuiControl,, ExResult, % Abs(Params*)
MsgBox Worked
ExitApp

Re: Crash in AHK 32bit

Posted: 31 Aug 2014, 19:07
by lexikos
Interesting. Does it crash if you pass valid parameters?

Re: Crash in AHK 32bit

Posted: 31 Aug 2014, 19:24
by TAC109
No. I encountered this crash in Pulover's Dynamic Function Tester. The screen attempts to refresh as you type in data. Attempts to type in negative numbers to the abs function crash if the hyphen is entered first.

Edit: This is with 'evaluate parameters as expressions' unchecked.

A circumvention is to replace line 4 with

z:=abs(params*)
GuiControl,, ExResult, % z

However, the original code should work.

Re: Crash in AHK 32bit

Posted: 31 Aug 2014, 20:25
by lexikos
Says who? "-" is not a number. The documentation does not say what happens when you pass invalid parameters.

One would generally not expect it to crash, but it shouldn't "work" either.

Re: Crash in AHK 32bit

Posted: 31 Aug 2014, 21:31
by TAC109
By 'work' I mean 'not crash'. In the circumvention 'z' evaluates to an empty string, as expected.

Re: Crash in AHK 32bit

Posted: 01 Sep 2014, 00:41
by lexikos
I think you missed my point, but I was wrong anyway.
Note: Math functions generally return a blank value (empty string) if any of the incoming parameters are non-numeric.

Re: Crash in AHK 32bit

Posted: 01 Sep 2014, 04:23
by lexikos
Your workaround may also fail. The crash occurs as a result of overwriting a pointer in an internal data structure with an indeterminate value. If that value happens to be something safe (by coincidence), there's no crash. Otherwise, it could crash the program or cause heap corruption, leading to other hard-to-trace problems. Your best bet is to avoid calling Abs with an invalid parameter.

In any case, it will be fixed in the next release.

Re: Crash in AHK 32bit

Posted: 01 Sep 2014, 17:09
by TAC109
lexikos wrote:In any case, it will be fixed in the next release.
Thanks

Re: Fixed - Crash in AHK 32bit

Posted: 10 Sep 2014, 03:59
by lexikos
Fixed in v1.1.16.01.