-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In-Game: array_copy() when "src_index" is invalid will silently crash the game, should show an error #7917
Comments
The behavior you're observing is expected. When the dest_index is out of bounds, the destination array is expanded, and the new elements are filled with zeros. This happens because we're writing to indices that don't exist, which triggers the array to grow. While this behavior might seem unusual, it is consistent with legacy design. However, the scenario you're describing involves an out-of-bounds src_index—meaning you’re trying to read from an invalid index in the source array. In this case, we don’t expand the array or fill it with zeros because accessing a non-existent index should not alter the source array. Instead, this scenario should result in an error or be safely ignored. Expanding the source array to accommodate an invalid read would not be the correct behavior. |
They were indeed silent crashes are these are NOT intended nor should happen. Those were fixed and to mitigate bad usage this extra information should be add to the manual explaining those edge cases:
@YYBartT @gurpreetsinghmatharoo test project for QA: |
YoYoGames/GameMaker-Bugs#7917 * Added that array_equals() works recursively and doesn't follow references (it compares the values instead) * Moved all notes under a "Usage Notes" section * Reworked the code example and added a second one that shows nested arrays and struct elements (reference types, more generally)
… crash the game, should show an error YoYoGames/GameMaker-Bugs#7917 * Updated array_copy page: * Added notes on the limitations on source and destination offsets (and ranges) and on inserted zeroes * Added a third code example "Extending the Destination Array" * Added link IDs to the headers on the Arrays page
Clarified the limitations on the source and destination array ranges on the |
@DiasFranciscoA So what was the fix? Do we have error messages returned when the user does this edgecase instead of a silent crash? Not sure what I'm expecting to see when I check your QA project + the original one. |
there shouldn't be silent crashes... the edge case that the user explains if he is reading out of bounds won't produce an error since values will always be clampped to the available size... if writing out of bounds this is acceptable and the array will expand in size to accomodate the values... the other silent crashing situations have been fixed. |
This is now fixed in the Nov24 branch with PR: |
Verified fixed in IDE v2024.1100.0.683 Runtime v2024.1100.0.705, as no more crashes are occurring |
…lete() negative offset & length YoYoGames/GameMaker-Bugs#7917 YoYoGames/GameMaker-Bugs#2785 * Added an item under "offset" on the Array Functions page to indicate it is clamped * Documented negative index and count for string_delete(), which was missing there (original ticket linked above)
Added a note about |
Description
it should either crash with an error message or have missing entries filled with zeros, like it is the case for using an out of bounds index for dest_index.
Steps To Reproduce
var src_array = [ 1, 2, 3 ]
var dest_array = [ 4, 5, 6 ]
array_copy(dest_array, 4, src_array, 1, 1)
show_debug_message($"dest_ind out of bounds, filled with 0's {dest_array}")
var dest_array = [ 4, 5, 6 ]
array_copy(dest_array, 1, src_array, 4, 1)
show_debug_message($"src_index out of bounds, will not get printed {dest_array}")
Which version of GameMaker are you reporting this issue for?
IDE v2024.8.1.171 Runtime v2024.8.1.218
Which operating system(s) are you seeing the problem on?
Windows 10.0.19045.0
Which platform(s) are you seeing the problem on?
Windows
2cfe6c82-021f-460d-af68-629cc27de693
The text was updated successfully, but these errors were encountered: