Skip to content
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

[Core] Prevent further infinite recursion when printing errors #89490

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Mar 14, 2024

Similar to:

The statistics method is only called when the queue runs out of memory anyway so it would always break things, while you can call it from elsewhere it's only called from within the queue at the moment, there's also a possible interlock issue as the mutex isn't unlocked until after the statistics method is called.

We could add some form of check to print differently if you call it manually, but I think it's fine this way, only unsure if it should be stdout or stderr

@AThousandShips AThousandShips added bug topic:core crash regression cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Mar 14, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Mar 14, 2024
@AThousandShips AThousandShips marked this pull request as ready for review March 14, 2024 19:38
@AThousandShips AThousandShips requested a review from a team as a code owner March 14, 2024 19:38
@AThousandShips
Copy link
Member Author

Realized there were more cases in this so replacing them all

@KoBeWi
Copy link
Member

KoBeWi commented Mar 14, 2024

The issue is more than that, so I wouldn't close it yet.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm it prevents Godot from taking infinite RAM in my case, but I can't say if the engine is doing anything else than printing errors forever. But at least it doesn't freeze the OS anymore.

@AThousandShips
Copy link
Member Author

AThousandShips commented Mar 14, 2024

Reworked the original error messages, converted one more ERR_PRINT to a fprintf to avoid any recursion there (fixing format strings, will push momentarily)

Got a crash when printing so will look at that first

Edit: I'll push the format fixes to this and look at the weird issue with the callable error separately, it's unrelated to this specific detail

@AThousandShips AThousandShips marked this pull request as draft March 14, 2024 21:22
@AThousandShips AThousandShips marked this pull request as ready for review March 14, 2024 21:26
@AThousandShips
Copy link
Member Author

AThousandShips commented Mar 14, 2024

There's a crash when flooding the queue with deferred calls, will investigate this weekend probably, related to custom callables being broken somewhere, probably a frees memory issue, but will do some digging when I can and open an issue

@AThousandShips AThousandShips force-pushed the queue_print_fix branch 2 times, most recently from ad5d915 to a0d346b Compare March 14, 2024 21:40
@AThousandShips AThousandShips marked this pull request as draft March 14, 2024 21:42
@AThousandShips
Copy link
Member Author

I'll switch to using itos as before for the ID, the fprintf seems to not agree across different platforms so just making it simple

@AThousandShips AThousandShips marked this pull request as ready for review March 14, 2024 21:44
@akien-mga akien-mga merged commit 7d4804e into godotengine:master Mar 15, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@AThousandShips AThousandShips deleted the queue_print_fix branch March 15, 2024 10:04
@AThousandShips
Copy link
Member Author

Thank you!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 8, 2024
@akien-mga
Copy link
Member

Doesn't apply to 4.1.

@akien-mga akien-mga removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Apr 8, 2024
@rune-scape
Copy link
Contributor

it does apply to 4.1...
i actually fixed it on my branch a bit ago. i missed this PR until just now bc i was found a different issue (below) that fit my description the issue and it wasnt linked here
it fixes #63298 i think

@akien-mga
Copy link
Member

it does apply to 4.1...

What I meant is that it does not cherry-pick trivially on the 4.1, as the code is somewhat different.
It doesn't mean it's not relevant for 4.1 code, but it would need a bespoke PR if it's important to fix there.

Given that I'm about to release 4.1.4-stable which may be the last release in that branch, I think it's not necessarily worth the trouble.

@AThousandShips
Copy link
Member Author

I'll take a quick look at the 4.1 code this afternoon and see how trivial a fix might be

@AThousandShips
Copy link
Member Author

AThousandShips commented Apr 13, 2024

Can make a 4.1 specific fix for the statistics part, but I don't think it's critical enough generally

Edit: I've made a dedicated fix for 4.1, can open a PR if desired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants