paulloz / godot-ink

Ink integration for Godot Engine.
MIT License
588 stars 41 forks source link

Calling RemoveParagraph() in MetaClicked event within RichTextLabel crashes Godot #75

Closed knochenhans closed 11 months ago

knochenhans commented 11 months ago

Hi, when printing text in a RichTextLabel, Godot crashes with the following log when I try to remove the last displayed paragraph using RemoveParagraph(GetParagraphCount() - 1); from within the MetaClicked event handler:

Godot Engine v4.1.3.stable.mono.official.f06b6836a - https://godotengine.org
Vulkan API 1.3.255 - Forward Mobile - Using Vulkan Device #0: AMD - AMD Radeon Graphics (RADV RENOIR)

ERROR: FATAL: Index p_index = 1 is out of bounds (count = 1).
   at: operator[] (./core/templates/local_vector.h:161)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.1.3.stable.mono.official (f06b6836a9ecfd0e6ec96d8bcf0fe9c9bc10dcbf)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.13/libcoreclr.so(+0x4b3b3e) [0x7faa7bcb3b3e] (??:0)
[2] /usr/lib/libc.so.6(+0x3e710) [0x7faac7371710] (??:0)
[3] /usr/bin/godot-mono() [0x932df0] (??:0)
[4] /usr/bin/godot-mono() [0x2fadca6] (??:0)
[5] /usr/bin/godot-mono() [0x482caa4] (??:0)
[6] /usr/bin/godot-mono() [0x2cce4c0] (??:0)
[7] /usr/bin/godot-mono() [0x4e937e5] (??:0)
[8] /usr/bin/godot-mono() [0x489feb0] (??:0)
[9] /usr/bin/godot-mono() [0x2ded6d3] (??:0)
[10] /usr/bin/godot-mono() [0xf25d86] (??:0)
[11] /usr/bin/godot-mono() [0xe55c54] (??:0)
[12] /usr/lib/libc.so.6(+0x27cd0) [0x7faac735acd0] (??:0)
[13] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7faac735ad8a] (??:0)
[14] /usr/bin/godot-mono() [0xe8843e] (??:0)
-- END OF BACKTRACE --
================================================================
The program '[333443] godot-mono' has exited with code 0 (0x0).

Here is the minimal code (also attached as a minimal project) for the RichTextLabel Node:

using Godot;
using System;
using GodotInk;

public partial class TextPanel : RichTextLabel
{
    public override void _Ready()
    {
        base._Ready();
        MetaClicked += GetChoice;

        AppendText("[url=0]Click me[/url]");
        Newline();
        AppendText("This should be deleted.");
        // Works here: RemoveParagraph(GetParagraphCount() - 1);
    }

    public void GetChoice(Variant meta)
    {
        // Crashes Godot here:
        RemoveParagraph(GetParagraphCount() - 1);
    }
}

richtexttest.zip

This might be related to an issue I originally created for Godot and that was fixed, but this similar issue here I was only able to trigger using godot-ink, so I’m a bit unsure where to put this :)

knochenhans commented 11 months ago

Sorry, this can be deleted. Turns out the original issue I linked to above is still present in Godot 4.1.3 itself.