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

Contents of exported .gdc files are non-deterministic #96854

Closed
mihe opened this issue Sep 11, 2024 · 0 comments · Fixed by #96855
Closed

Contents of exported .gdc files are non-deterministic #96854

mihe opened this issue Sep 11, 2024 · 0 comments · Fixed by #96855

Comments

@mihe
Copy link
Contributor

mihe commented Sep 11, 2024

Tested versions

Reproducible in 4.4.dev [4788f54]

System information

Windows 11 (10.0.22631)

Issue description

I've been debugging an issue related to #64712, where the new binary token support for GDScript exports will for whatever reason randomly result in them being written to the PCK file with a new hash most of the time, despite the contents of the *.gd file being identical.

The reason for this seems to be that the contents themselves are in fact actually different. More specifically there is a gap in the written to contents at bytes 13-16, as seen here:

Vector<uint8_t> contents;
contents.resize(20);
encode_uint32(identifier_map.size(), &contents.write[0]);
encode_uint32(constant_map.size(), &contents.write[4]);
encode_uint32(token_lines.size(), &contents.write[8]);
encode_uint32(token_counter, &contents.write[16]);

Since Vector::resize is what's being used there, as opposed to Vector::resize_zeroed, you will end up with 4 random bytes being written into the .gdc file, resulting in the contents (and thus the hash) being different with every export, which will be problematic for the pending patch system in #64712.

Steps to reproduce

N/A

Minimal reproduction project (MRP)

N/A

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

Successfully merging a pull request may close this issue.

2 participants