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
Conversation
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; |
There was a problem hiding this comment.
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.
@monojenkins squash |
should we backport this change? |
yes, I set the target for -06 or do you consider it to be too risky? |
@monojenkins backport to 2018-08 |
@monojenkins backport to 2018-06 |
[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
This could lead to crashes when having strings with size at the LOS boundary.
#10309