|Anonymous | Login | Signup for a new account||2017-12-12 06:35 GMT|
|My View | View Issues | Roadmap | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0016912||Runner||[All Projects] Functions||Public||2015-01-03 01:25||2017-11-27 13:28|
|Assigned To||Russell Kay|
|Priority||High||Severity||A - Crash/Hang||Reproducibility||100%|
|Status||Resolved||Resolution||No Change Required|
|Platform||Windows||OS||Windows 8||OS Version||8.1|
|Summary||0016912: Functions: User-defined array_get function overrides [@] operator? [and crashes the game]|
|Description||Consider the following. There is a function named array_get, which, as you may have guessed, pulls a value out of the array. The code is rather straightforward,|
#define array_get /// array_get(this, index:Int):T var this = argument, index = argument; show_debug_message("array_get(" + string(this) + ", " + string(index) + ")"); return this[@index];
(show_debug_message added for clarity)
But what happens on the call is the most interesting - instead of pulling a value out of array, the function recurses into itself and the game process dies to a stack overflow. To further confirm the fact of recursion, changing "index" to "index + 1" will display rapidly increasing stack depth to the point of crash.
This is not exactly a documented feature, is it?
|2.x Runtime Version|
|2.x Runtime Version Verified In|
|Attached Files||array_get.gmz [^] (21,444 bytes) 2015-01-03 01:25|
|My further research has shown that there are similar functions for other access operators. I'd like to suggest these to be included in built-in function lists (but not auto-completion) to both secure them from being overriden and to allow easier use from user-defined code (for example, you could do array_get(get_some_array(), column) instead of having to assign array to an intermediate variable).|
Russell Kay (Manager)
|There are several built in functions that are used for implementing the array accessors - they have now been added so a Game Script cannot be called that - at the moment though you can still call an Extension function that (and override the built in function)... we really should fix that to disallow that behaviour... we will consider that.|
To add here, a ds_list accessor function does something that is not possible to do with built-in functions - it expands the list if needed, unlike the ds_list_replace function that will only change the existing indexes.
I have also discovered that adding a function to the extension file without an implementation exposes it for use without crashing the game, but I would very much prefer to see these to in the built-in function list (similar to action_* group).
Russell Kay (Manager)
|This has been mitigated through various error messages and is still possible but difficult to do - closing|
|Copyright © 2000 - 2017 MantisBT Team|