Merged
Conversation
Crash 1 (at network_downloader.cpp:61): This crash happened when the app would attempt to copy the vector data to put it into the map. This fix is technically more of a workaround, as it prevents the vector from getting copied, and instead converts it into a rvalue by std::moving it, which means it doesn't need to be copied and can directly be put into the map Crash 2 (at draw.cpp:123): This crash would happen when the code attempted to set c2d_image->subtex->top to 1.0. This happened because Draw_c2d_image_init didn't allocate the right amount of memory. Instead of allocating the sizeof(Tex3DS_SubTexture) and sizeof(C3D_Tex), it allocated the size of their pointers, meaning it just allocated 4 bytes two times and not the size of the structure. This meant that in linear space, there would be 8 allocated bytes in a row, which fit the width and height, which are both u16 values, filling 4 bytes, and the left variable, which is a 32-bit float, which is 4 bytes, and fills the allocated RAM. When attempting to set top, which happens at an offset of exactly 8 bytes, it wanders off into unallocated memory, which is known as undefined behavior and leads to random segfaults.
Collaborator
|
Thank you so much. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crash 1 (at network_downloader.cpp:61): This crash happened when the app would attempt to copy the vector data to put it into the map. This fix is technically more of a workaround, as it prevents the vector from getting copied, and instead converts it into a rvalue by std::moving it, which means it doesn't need to be copied and can directly be put into the map
Crash 2 (at draw.cpp:123): This crash would happen when the code attempted to set c2d_image->subtex->top to 1.0. This happened because Draw_c2d_image_init didn't allocate the right amount of memory. Instead of allocating the sizeof(Tex3DS_SubTexture) and sizeof(C3D_Tex), it allocated the size of their pointers, meaning it just allocated 4 bytes two times and not the size of the structure. This meant that in linear space, there would be 8 allocated bytes in a row, which fit the width and height, which are both u16 values, filling 4 bytes, and the left variable, which is a 32-bit float, which is 4 bytes, and fills the allocated RAM. When attempting to set top, which happens at an offset of exactly 8 bytes, it wanders off into unallocated memory, which is known as undefined behavior and leads to random segfaults.
If you have any questions or complaints, please ask, I will be happy to respond and discuss any potential issues, as I am not sure if any of my changes may be break something else in the codebase