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

[Net] Fix Marshalls infinite recursion crash. #51068

Merged
merged 1 commit into from
Jul 30, 2021

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented Jul 30, 2021

Variants like dictionaries and arrays can have cyclic references, which caused encode_variant to run an infinite recursion.
Instead of keeping a stack and looking for cyclic references which would make serialization slower, this commit adds a MAX_RECURSION_DEPTH constant to Variant, and have encode_variant keep track of the current recursion depth, bailing when it's too high since this likely means a cyclic reference has been encountered.

Fixes #51049

@Faless Faless added bug topic:core topic:network crash cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jul 30, 2021
@Faless Faless added this to the 4.0 milestone Jul 30, 2021
@Faless Faless requested a review from a team as a code owner July 30, 2021 13:56
@Faless Faless requested a review from reduz July 30, 2021 13:56
core/io/marshalls.cpp Outdated Show resolved Hide resolved
Variants like dictionaries and arrays can have cyclic references, which
caused `encode_variant` to run an infinite recursion.
Instead of keeping a stack and looking for cyclic references which would
make serialization slower, this commit adds a `MAX_RECURSION_DEPTH`
constant to Variant, and have `encode_variant` keep track of the current
recursion depth, bailing when it's too high since this likely means a
cyclic reference has been encountered.
@Faless Faless force-pushed the net/4.x_marshalls_recurse branch from 640af6f to 3246364 Compare July 30, 2021 14:14
@akien-mga akien-mga merged commit c27ef15 into godotengine:master Jul 30, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.4.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Aug 3, 2021
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.

Game crashes when debugging the project (infinite recursion after ScriptDebuggerRemote::_put_variable)
2 participants