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

[sgen] Fix string size inconsistency between alloc/scan #10355

Merged
merged 1 commit into from Aug 30, 2018

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Aug 29, 2018

This could lead to crashes when having strings with size at the LOS boundary.

#10309

This could lead to crashes when having strings with size at the LOS boundary.

mono#10309
@@ -6998,7 +6998,7 @@ mono_object_get_size (MonoObject* o)

MonoClass* klass = mono_object_class (o);
if (klass == mono_defaults.string_class) {
return sizeof (MonoString) + 2 * mono_string_length ((MonoString*) o) + 2;
return MONO_SIZEOF_MONO_STRING + 2 * mono_string_length ((MonoString*) o) + 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

To illustrate the issue, see: https://gcc.godbolt.org/z/g1rhHc

It wasn't obvious to me that sizeof includes the empty chars array. Good catch.

@lewurm
Copy link
Contributor

lewurm commented Aug 30, 2018

@monojenkins squash

@monojenkins monojenkins merged commit 609f653 into mono:master Aug 30, 2018
@lewurm
Copy link
Contributor

lewurm commented Aug 30, 2018

should we backport this change?

@marek-safar
Copy link
Member

yes, I set the target for -06 or do you consider it to be too risky?

@BrzVlad
Copy link
Member Author

BrzVlad commented Aug 31, 2018

@monojenkins backport to 2018-08

@BrzVlad
Copy link
Member Author

BrzVlad commented Aug 31, 2018

@monojenkins backport to 2018-06

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
[sgen] Fix string size inconsistency between alloc/scan

This could lead to crashes when having strings with size at the LOS boundary.

mono/mono#10309



<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->



Commit migrated from mono/mono@609f653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants