godot: Infinite loop in rich_text_label.cpp (ERROR: _process_line: Index line = 0 is out of bounds)
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version: Godot 3.2.2.beta1
OS/device including version: MacOSX 10.14.6 (18G95)
Issue description: Today all day I’m working on fixing pvrtc and twice my godot did hung up with this errors:
At: scene/gui/rich_text_label.cpp:170.
ERROR: _process_line: Index line = 0 is out of bounds (l.offset_caches.size() = 0).
At: scene/gui/rich_text_label.cpp:170.
ERROR: _process_line: Index line = 0 is out of bounds (l.offset_caches.size() = 0).
At: scene/gui/rich_text_label.cpp:170.
ERROR: _process_line: Index line = 0 is out of bounds (l.offset_caches.size() = 0).
At: scene/gui/rich_text_label.cpp:170.
ERROR: _process_line: Index line = 0 is out of bounds (l.offset_caches.size() = 0).
It repeats in infinite cycle and godot interface is frozen. I can not reproduce it when I want to. But two times it happened.
Steps to reproduce:
Minimal reproduction project:
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 33 (18 by maintainers)
Not sure if it’s related but this issue consistently happens since I tried adding multi-threading to my addon. I’ll see if I can produce a minimal reproduction project but the code is so convoluted I’m having a hard time tracking down this issue.
I’ve ran into this using 3.4 stable. Where the editor will indefinitely freeze up while continuously outputting:
Index line = 0 is out of bounds (l.offset_caches.size() = 0).It happens with my plugin when threading and printing is involved.
Removing the print statements stopped the editor from outputting this error and freezing.
I have created a minimal reproduction project for this issue.
In order to see the issue enable the plugin and make sure that the Godot editor output console is visible. After a few seconds it will start producing the error.
Note that if the editors output is not visible the error won’t occur but the editor will soon freeze once it’s visible.
The error is produced by calling this function within a thread created by the plugin:
Note that decreasing the delay will cause the output text to become increasingly more garbled
richTextError.zip
I am running into the same issue.
My minimal reproduction project does not contain any scenes, scripts, exporting, or anything with threads. It is three nearly empty resource files and a project.godot
Godot version
Tested on both Mac and Linux
Reproduced with
scons platform=osx arch=arm64 target=release_debugLinux:scons platform=x11 arch=x64 target=release_debugUnable to reproduce with
scons platform=osx arch=arm64 target=debugLinux:scons platform=x11 arch=x64 target=debugSystem information Mac M1 Ubuntu 20.04.1
Steps to reproduce
Extract the zip file somewhere, and cd into it
Clear the cache and launch the editor from the command line
Mac
Linux
In the editor, click on
Outputto view the output. You should see something similar to this.Outputwindow must remain open to reproduce the bug, so leave it open.Right click on
dynamicfont.tres, then choose “Duplicate” and give it a different name.dynamicfont.tresjust once reproduces the problem. On Linux I’ve had less luck, where I’d have to duplicatedynamicfont.tres(or any of the duplicates) 5 to 10 times (and even quit the editor, clear the cache, and restart the editor) before the bug occurs.Watch the editor freeze.
This error message is spammed in the terminal
Video (from Mac, but similar is seen on Linux) https://user-images.githubusercontent.com/109488824/189353599-4b3b4373-d20c-471e-9cc7-1c54aeadcdbe.mp4
Minimal reproduction project DynamicFontInfiniteLoop.zip
Notes
As mentioned earlier, the
Outputwindow must be opened to reproduce the bug. I suspect thatOutputis implemented with a rich_text_label.When you duplicate a resource, and the bug does not occur, you must see something like this in the
OutputIf you only see
Then the bug has no chance of happening. To see the bug, Godot must “reload” the resource when you duplicate it. To make this happen, exit the editor, clear the cache, and restart the editor Alternatively, name the duplicate resource something unique (in my case,
b.treshasn’t been used in any editor session yet)The reproduction steps clear the Godot cache. This is to ensure duplicated resources are “reloaded”, even if Godot has loaded that file in a previous editor session. For example, if a previous editing session loaded
a.tres, then Godot will not reload it unless if the cache was cleared before launching the editor.-v(--verbose) makes it reproducible 100% of the time. In this minimal project, I wasn’t successful in reproducing the failure without-v. In my actual project, the failure seemed random when-vwas omitted since it only happened when Godot would also load the duplicate resource. It is obvious when Godot loads the duplicate resource because I had code that printed text when_init()was called.The
DynamicFontresource (dynamicfont.tres) must load two or moreExtResources. I couldn’t reproduce the problem withSubResourcesnor with only oneExtResource.This minimal project points to two
ttffonts that do not exist. The problem occurs regardless if they point to realttfs or not.