Why would one string crash the engine but another does not?

Godot Version

4.3

Question

I am generating upgrade cards. So far I have eight different cards all extending a base class. For some reason I experienced game crashes and my normal debugging methods did not work, it was like the entire engine froze.

Eventually, after about two days of hair pulling, I have discovered that the content of this string is the problem.

var card_description: String = "Strengthen your shield capacity to absorb more damage, allowing you to withstand battles for longer."

This made the specific Shield upgrade card not work. But when I replace the content of the string with something else like this:

var card_description: String = "Strengthen your shield to withstand battles for longer."

Everything is fine.

I though maybe there was some hidden character in the first string, but I cannot find anything hidden in there.

Does anyone have any idea why this might have happened? It seems really weird to me. With the first string the engine seems to freeze. With the latter or any other string, everything is fine? This happened in two cards of eight and although I was cutting and pasting content from a text editor, where I wrote the things in the first place, they all orginated from the same text editor. In this case it was Obsidian, but I don’t think that is relevant.

Thankyou in advance for any advice or insights into this.

PS If I cut and paste the original string back in, the whole thing breaks again!

So if you type the first string yourself inside the engine it also breaks?
if yes: what exactly do you do with those strings?
if no: compare the string when you convert it to bytes with the copied one to see the differences

Yes, if I retype it in the editor it still breaks.

All I do is use it to update a label like this:

	card_data["card_description_text"] = self.card_description

Again, this works for 6 out of eight cards, but not this card.

Oddly I started deleting the text string bit by bit, and when I delete 18 chars (still testing this) from anywhere, it works again. However, I have other cards with longer descriptions that work fine. There is something about this string that is breaking things. It is not a normal break either, the engine just seems to stop working. Even when I have a print statement way before this is even called, those don’t print. In fact no errors are shown at all, the whole thing freezes, and after about 15 seconds, the play window just closes and returns to the editor. During that time, even if I pause the game, the remote tree is blank!

have you opened godot with the cmd-open to display error messages?

I have never done that but will try now. It’s a good idea.

BTW, it seems that I only have to delete 8 chars for the breaking line to work? I have absolutely no idea what could possibly be going on here.

Do you know at which specific point in code it breaks?

That is the odd thing. So the player ship collects orbs. When each orb is collected I print(“orb collected”). When I reach a limit, the upgrade cards show. When I only generate the working cards, I get three “orb collected” messages and then other messages like “generating cards”, “card 1 called”, “card 1 generated”, “card 2 called”, “card 2 generated” etc.

However, when I generate the shield upgrade card, which is called way after orb collection, the third “orb collected” never shows, the whole engine freezes, and if I pause it and look at the remote tree, it is blank! No error messages are displayed. If I change the content of that string only, everything works fine.

The orb collection has nothing, absolutely no relation to the generating of upgrade cards. And when I shorten the string by it seems any 8 chars, it works again! Yet other cards have longer descriptions and work fine.

PS Still trying to get the cmd-open from command line

usually you have an exe in your installation folder that opens it automatically when you start it. or just open the cmd in your godot installation folder and start godot from there.

Are you on windows?

@herrspaten Thanks that helped.

I get an error that an object was deleted whilst waiting for a callback.

Failed method: CanvasItem::_redraw_callback. Message queue out of memory. Message queue out of memory. Try increasing .

Hmm.

okay apparently not enough memory

try to start your game with the profiler/monitor open and see if something suspicious is happening

Again though, If I delete 8 chars from the apparently offending string, all is fine.

I will see what might be happening. The debug monitor shows only 60MB being used though. And yes this is windows but I have plenty of RAM.

This command line debug thing is excellent, have not used it before.

The project settings have a message queue size option under “Memory”. Try to increase it

I increased the message queue from 32MB to 64MB. No difference.

I tried to find a deleted object before the callback was completed, but nothing makes any sense here. The cards appear, nothing is deleted or removed before the ‘select’ button is pressed. And the cards never show.

I have change nothing, but the error log on command line window is now saying:

Failed method: Control::_update_minimum_size.

Again, I do not update a progress bar minimum size until an upgrade is selected. Although I have discovered that max_value of a progress bar is a float, and I am using an int. I will change this but I don’t think this is the problem.

Again though, I tried a longer working description for my shield card. So the first one does not work, the second one does work (I comment one of the two out of course in the code)

# orig breaks everything
var card_description: String = "Strengthen your shield capacity to absorb more damage, allowing you to withstand battles for longer."
# copied from acceleration card which works fine for shield too and nothing breaks
var card_description: String = "Improved acceleration, enabling you to reach top speed quicker, but at the cost of more power."

I am going to take a break. I have fixed the problem, but I have no idea why the problem happened in the first place. I am worried that my game is now super fragile with an issue that I have that I am unable to identify. I cannot fathom why one description works and the other description breaks everything.

:frowning:

No matter how you solve it. I think its worth opening up a github issue

The only real difference between strings is the length.
Are you animating the text?

I recommend you open an issue on Godot github to check this problem, if the engine is crashing that is a bug that needs to be solved.

Just by curiosity, you’re using this string in some Label, RichText, LineEdit or TextEdit node inside a container node? Because i remember see this message in a bug related to resizing nodes inside a container.

I was updating a label.

CanvasLayer → Control → VBox → VBox → MarginContainer → MarginContainer → VBox → VBox → Label

It was part of a fairly complex structure, that is built from sub components and then added to the tree.

I have tried to recreate this in a more simple scene but I have not been able to. I think it is a problem with resizing an element, and I am starting to believe that it is a bug, however whenever I have thought this in the past, it has always turned out to be something I was doing incorrectly. Since I cannot recreate it in a minimal project, I am not sure how I would share the issue without sharing my entire game project.

I have been thinking about this, and although shortening the string seems to fix it, I am not happy to continue with something so fragile. So I am going to change my approach to this game mechanic entirely, and approach it in a completely different way.

Thank you for your help in exploring this issue, I really appreciate it, and although it has not been ‘solved’, I feel like I have to move on, so a restructure and different approach seems the best way to go for now.

Because i remember see this message in a bug related to resizing nodes inside a container.

Can you recall where you saw this? That sounds just like the issue I am having.

Again, if not, thank you again for your support, I have really appreciated it.

Thanks,

Paul

The Message queue out of memory. Try increasing is not about your PC being out of memory, generally this happens because of an infinite recursion that consumes all the allocated memory of the MessageQueue.

The thing about the String can be the bigger String makes the Label resize, and when a node inside a container resize, the container needs to handle this to sort the nodes correctly, but in some specific situations this can lead to the container making the node resize again, that makes the container handle the resize and resize the node again until the engine crash.

1 Like

That sounds exactly like what is happening here.

when i type something in the label node godot freezes until the crash, when the crash happens vscode shows the printed error: Failed method: Control::_update_minimum_size. Message queue out of memory. Message queue out of memory. Try increasing memory/limits/message_queue/max_size_mb’ in project settings. and a spam of: Object was deleted while awaiting a callback.

I will try and reproduce it again today and see if I can get a minimum project to reproduce and report.

TBH I am relieved that my code structure or implementation was not necessarily the issue here. This is the first time I have run into a bug!

Thank you again!