godot: Game crashes if it has a 3D camera and windowsize is reduced to 1 pixel wide/tall.

Godot version: Godot 3.0.3

OS/device including version: Ubuntu 18.04 64bit on AMD Cayman (HD 6950) and Mesa 18.0.0-rc5. Intel® Core™ i5-4570 CPU @ 3.20GHz × 4

Issue description: In a 3d scene with camera, if scene is played in windowed mode and the user reduces the size of the window to 1 pixel (or less) tall or wide, the game will silently crash.

tinywindowbug

This bug gives the following terminal output when launched from Godot editor

ERROR: operator[]: FATAL: Index p_index=0 out of size (size()=0)
   At: core/vector.h:138.
handle_crash: Program crashed with signal 4
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f995f509f20] (??:0)
[2] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0xbd5267] (<artificial>:?)
[3] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0xc0af84] (<artificial>:?)
[4] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0xc84ffa] (<artificial>:?)
[5] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x176879d] (<artificial>:?)
[6] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x1769377] (<artificial>:?)
[7] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x1784be0] (<artificial>:?)
[8] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x17872d1] (<artificial>:?)
[9] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x85e435] (??:?)
[10] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x6ce7ad] (??:?)
[11] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f995f4ecb97] (??:0)
[12] /home/johannesg/bin/Godot_v3.0.3-stable_x11.64() [0x6dabbe] (??:?)
-- END OF BACKTRACE --

This bug gives the following terminal output when the project is exported and launched directly.

ERROR: operator[]: FATAL: Index p_index=0 out of size (size()=0)
   At: core/vector.h:138.
Illegal instruction (core dumped)

Steps to reproduce:

  1. Create a new scene with only a 3d Camera.
  2. Play the scene
  3. Resize window so that it takes up as little vertical or horizontal space as possible. 1 pixel or less.

Minimal reproduction project:

TinyWindowBug.zip

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I should correct my own previous statement : it’s also crashing in X11 with glow enabled 😢 Thanks to @lekoder narrowing down the problem, I found that it is coming from this line :

glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger

in file rasterizer_scene_gles3.cpp (around line 3931). The problem is that when the window is reduced to 0 in width or height, the array storage->frame.current_rt->effects.mip_maps[0].sizes only has 1 dimension, so trying to acces [i+1] is impossible, i having a value from 0 to max_glow_level+1

My first try was simply

if (storage->frame.current_rt->effects.mip_maps[0].sizes.size() > i + 1)
    glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger
else
    glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);

and no more crash no matter how I resized the window, but it’s like the first bug from the OP, I just put a patch, not a solution 🤔 For the solution, I don’t exactly know how to correct it, @taylorjoshuaw could you please take a look at it ?

Hi,

I can confirm this bug using master from 5c5aafa

I could trace it down to RasterizerSceneGLES3::_post_process in file drivers/gles3/rasterizer_scene_gles3.cpp

Here is the result of exporting test project in debug and reducing window’s height down to 0 : crash tinywindow

Only solution I found to limit this problem was to add

	if (storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0)
		return;

just before

	if (storage->frame.current_rt->buffers.active) {
		//transfer to effect buffer if using buffers, also resolve MSAA

in function _post_process around line 3584 in file drivers/gles3/rasterizer_scene_gles3.cpp

But I think the real solution would be to find why the array storage->frame.current_rt->effects.mip_maps[0].sizes becomes null… am I wrong ?