[Solved V2a0.52]crash if __Call(FormalParameter) when %o%()

Report problems with documented functionality
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

[Solved V2a0.52]crash if __Call(FormalParameter) when %o%()

18 Sep 2014, 09:11

Code: Select all

o:=new c
%o%()	;Use this 'method'
o.m()	;Fine
class c{
	__Call(a){	;Crush if there is a 'formal parameter' like 'a'
		return
	}
}
V2-a0.48 works OK, since V2-a0.50+.
Last edited by RobertL on 21 Sep 2014, 06:30, edited 5 times in total.
我为人人,人人为己?
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: V2-a0.50 crush if __Call(FormalParameter) when %o%()

18 Sep 2014, 09:21

Oh!? a0.52~Haha, I will try.
我为人人,人人为己?
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: [fixed]V2-a0.50 crush if __Call(FormalParameter) when %o

18 Sep 2014, 09:34

Sorry, the problem still exist in V2 a0.52.
我为人人,人人为己?
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: V2-a0.50+ crush if __Call(FormalParameter) when %o%()

18 Sep 2014, 15:58

I got it now, for me it only crashed on Win8.1 64-bit when running ahk in 32 bit.
As I understand v1 has the same issue.

params[0]->marker_length = 0; should solve that as I understand: script_expression.cpp->ExpandExpression()

Code: Select all

			if (!func)
			{
				// This is a dynamic function call.
				if (!stack_count) // SYM_DYNAMIC should have pushed a function name or reference onto the stack, but a syntax error may still cause this condition.
					goto abort_with_exception;
				stack_count--;
				func = TokenToFunc(*stack[stack_count]); // Supports function names and function references.
				if (!func)
				{
					// This isn't a function name or reference, but it could be an object emulating
					// a function reference.  Additionally, we want something like %emptyvar%() to
					// invoke g_MetaObject, so this part is done even if stack[stack_count] is not
					// an object.  To "call" the object/value, we need to insert an empty method
					// name between the object/value and the parameter list.  There should always
					// be room for this since the maximum number of operands at any one time <=
					// postfix token count < infix token count < MAX_TOKENS == _countof(stack).
					// That is, each extra (SYM_OPAREN, SYM_COMMA or SYM_CPAREN) token in infix
					// effectively reserves one stack slot.
					if (actual_param_count)
						memmove(params + 1, params, actual_param_count * sizeof(ExprTokenType *));
					// Insert an empty string:
					params[0] = (ExprTokenType *)_alloca(sizeof(ExprTokenType));
					params[0]->symbol = SYM_STRING;
					params[0]->marker = _T("");
					params[0]->marker_length = 0;
					params--; // Include the object, which is already in the right place.
					actual_param_count += 2;
					extern ExprOpFunc g_ObjCall;
					func = &g_ObjCall;
				}
				// Above has set func to a non-NULL value, but still need to verify there are enough params.
				// Although passing too many parameters is useful (due to the limitations of variadic calls),
				// passing too few parameters (and treating the missing ones as optional) seems a little
				// inappropriate because it would allow the function's caller to second-guess the function's
				// designer (the designer could provide a default value if a parameter is capable of being
				// omitted). Another issue might be misbehavior by built-in functions that assume that the
				// minimum number of parameters are present due to prior validation.  So either all the
				// built-in functions would have to be reviewed, or the minimum would have to be enforced
				// for them but not user-defined functions, which is inconsistent.  Finally, allowing too-
				// few parameters seems like it would reduce the ability to detect script bugs at runtime.
				// Param count is now checked in Func::Call(), so doesn't need to be checked here.
			}
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: V2-a0.50+ crush if __Call(FormalParameter) when %o%()

18 Sep 2014, 21:04

I'm using XP 32bit
我为人人,人人为己?
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: V2-a0.50+ crush if __Call(FormalParameter) when %o%()

18 Sep 2014, 21:30

Thanks. I thought I had ensured all instances of marker = _T("") were accompanied with marker_length = 0 or replaced with SetValue(_T(""), 0), but I missed that one.

Fixed in v2.0-a053.
HotKeyIt wrote:As I understand v1 has the same issue.
No; until v2.0-a050, marker_length was only used with mem_to_free.


Btw RobertL,

crush
1. deform, pulverize, or force inwards by compressing forcefully.
2. violently subdue (opposition or a rebellion).

crash
4. (of a computer, computing system, or software) fail suddenly.
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: V2-a0.50+ crush if __Call(FormalParameter) when %o%()

19 Sep 2014, 03:26

Thank you, both.

The explanation about 'crush' in English has many new words as 'crush' itself for me.
After knowing they are different, consult a En-Ch dictionary is some more fit for me.
我为人人,人人为己?

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 14 guests