-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Game crashes on range(0,100000000) #3756
Comments
Steps to reproduce? Is that a regression or did you just happen to try iterating over 100 million elements, which is likely not possible with single float precision? |
It does give a segfault with a |
I agree with @vnen. Debugger should catch this. |
Yeah I did not mean that it shouldn't be fixed, only that a oneliner bug report is always a bit too short :) |
Maybe VALIDATE_ARG_NUM should catch integer overflows? godot/modules/gdscript/gd_functions.cpp Lines 131 to 139 in 7af864f
|
It looks like GDScript's I also tested using a |
Yeah, it should really be worth a look to optimize for loops with range() to a while loop. @akien-mga single precision floats have 23 bits in their fraction part. That means everything up to 2^32 - 1 should be fine, including 100 million. I've reproduced the bug on commit 6a25a64 with gdb, and got this backtrace:
So it crashes in |
I found the problem. Let's look at the definition of _FORCE_INLINE_ int _get_alloc_size(int p_elements) const {
return nearest_power_of_2(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
} So, it does a multiplication How to solve this bug? Well, first step would be to use the more proper type |
* Add overflow checked intrinsic abstractions that check on overflow. * Use them for memory allocation code. * Use size_t type for memory allocation code to support full platform dependent width. Fixes godotengine#3756.
Still, it's not sane to allocate 2.4GB of memory just for a loop. |
Yes, having |
Yeah, that'd be a breaking change for sure. There's no easy way to make |
* Add overflow checked intrinsic abstractions that check on overflow. * Use them for memory allocation code. * Use size_t type for memory allocation code to support full platform dependent width. Fixes #3756.
I get a Game crash on
range(0,100000000)
and no error messages.The text was updated successfully, but these errors were encountered: