Modify

Opened 9 years ago

Closed 4 years ago

#3165 closed Bug (Fixed)

Call() function called with an empty array results in APPCRASH

Reported by: Rnde Owned by: Jon
Milestone: 3.3.15.4 Component: AutoIt
Version: 3.3.15.3 Severity: None
Keywords: Call, Ubound, Array Cc:

Description

AutoIt3.exe APPCRASH error upon calling Ubound() via Call():

Local $array[0]
$n = Call("Ubound", $array)

Attachments (0)

Change History (9)

comment:1 Changed 9 years ago by BrewManNH

  • Summary changed from Ubound() called with Call() function on 0-sized arrays results in APPCRASH to Call() function called with an empty array results in APPCRASH

You need to put the argument for the UBound inside quotes, otherwise you're not telling the function to use UBound on the array, you're telling the Call function that you're sending it an array of parameters, and because there are no parameters it crashes.

Local $array[0]
$n = Call("UBound", "$array")

It's a bug that it crashes because of this, but the bug is not what you think it is.

I've corrected the title of the bug report to reflect the actual bug condition.

comment:2 Changed 9 years ago by Rnde

I have tried your suggested method, it always returns 0 regardless the array's size.

Local $array[] = [1,2,3]
$n = Call("UBound", "$array")

comment:3 Changed 9 years ago by BrewManNH

When I run that I get an error message telling me that $array isn't an array or a map, it's possible that you can't use UBound in Call for some reason.

I'd avoid using Call at all if possible, it's almost never needed, and with this example definitely isn't.
But that's beside the point in this instance as I don't know if there's a bug in Ubound or a bug in using Call with UBound.

comment:4 Changed 4 years ago by jchd18

  • Resolution set to Fixed
  • Status changed from new to closed

Current release/beta versions of AutoIt work as intended.

Local $array = [1,2,3]
Local $n = Call(UBound, $array)
ConsoleWrite($n & @LF)

correctly shows 3

comment:5 Changed 4 years ago by anonymous

jchd18.... NO! sorry not sorry
It is NOT fixed. Firstly, tho not most importantly, a fix necessitates a change to the current codebase. Where's that here? Unthinkable to umm... think... that imaginary Fixes would count, but, well, i dunno, maybe they do and that's controversial?

However if one is willing to admit a possibility of hastily --
(good gosh, its been 5 -five!- efficking years! I don't think that this excuse will.. errm... excuse anyone involved, now will it?!)
hastily made incorrect, nay, wrong "judjmehnt" (sic), then, well... it could make this mess less bad. it might even, y'know... fix it!... *bu-dum ts-- oh no! dish falls, bounces off the floor, breaks the wall in half!! Quick! Get the FlexTape(c)(r)(tm)! Alternativelyyy~
perhaps a wee bit of common sense will fi-- i mean, suffice to fik... err. well you know! that!! and the dish Call'd be as new! Call'd be fi-- ohsorrie, NOT BROKEN!!!!!!!!!!!!!!!! :> y'know! ;) Alternatively still we could just aVoId UsiNg Call At aLL (c) BrewManNM, circa 5 BCY (Before Current Year)
like, i mean, why wouldn't that work, amirite? or, y fix the codes if you can fix the coders[' crooked wishes]? very useful!*

'niway here's a proper reproducer, tested with v3.3.14.1 and v3.3.15.0 and v3.3.15.3. when array has zero size(only 1D), Call crashes the program, regardless of function it is given. seems simply there's no check in Call for zero-sized 1D array.

if array.dimensions==1 AND array[0]=='CallArray..orWhatsItsNameWhoCares' then ...
else ... 

-- perhaps could be --

if array.dimensions==1 AND array.size>0 AND array[0]=='Yeah...that...' then ...
else ...
Global $array[1]
ConsoleWrite('--- with $array of size 1 ---' & @CRLF)
ConsoleWrite("call(fun1, $array)  --->  "&@tab)
$ret=call(fun1, $array)
ConsoleWrite('@err='&@error&', @ext='&@extended&', $ret='&$ret   &@CRLF)

ConsoleWrite("call(UBound, $array)  --->  "&@tab)
$ret=call(UBound, $array)
ConsoleWrite('@err='&@error&', @ext='&@extended&', $ret='&$ret   &@CRLF)

Global $array[0]
ConsoleWrite('--- with $array of size 0 ---' & @CRLF)
ConsoleWrite("call(fun1, $array)  --->  "&@tab)
$ret=call(fun1, $array)
ConsoleWrite('@err='&@error&', @ext='&@extended&', $ret='&$ret   &@CRLF)

ConsoleWrite("call(UBound, $array)  --->  "&@tab)
$ret=call(UBound, $array)
ConsoleWrite('@err='&@error&', @ext='&@extended&', $ret='&$ret   &@CRLF)

Func fun1($v)
	Return 1
EndFunc

ps.: oh yes, it could be longer xD but sorry anyway.

comment:6 Changed 4 years ago by anonymous

pps.: deer jchd18 (sorry i dont know your spiritual animal, so deer will have to do), if above post-wall in any way sounded ad hominem/personalized, plz know that's complitely unintentional, the issue does after all seem like a very easy-to-miss lil oversight. but, see, the times we're in... or was it weather?.. well, you know, it takes some toll. you're alright, so far as i can tell from lurking, which perhaps is irrelevant, but still. Have a nice day/month/millenia, as well as food, too. it's important! :D

comment:7 Changed 4 years ago by jchd18

  • Resolution Fixed deleted
  • Status changed from closed to reopened
  • Version changed from 3.3.14.2 to 3.3.15.3

comment:8 Changed 4 years ago by Jpm

  • Owner set to Jpm
  • Status changed from reopened to assigned

Hi,
fix sent to Jon

comment:9 Changed 4 years ago by Jon

  • Milestone set to 3.3.15.4
  • Owner changed from Jpm to Jon
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed by revision [12556] in version: 3.3.15.4

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.