diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-08-19 16:46:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-19 16:46:07 +0300 |
commit | 1e649b6338669d32c92bc882af968f68e4c14896 (patch) | |
tree | cc1b20a41987d65841ad2cd3c748ea38173e39d7 | |
parent | f41fc8b1333ac74e21e31ffdfa56281e7b20816e (diff) |
[Mono.Profiler.Aot] Write true string wire length (#21196)mono-6.12.0.150
In some cases, it seems like Mono.Profiler.Aot `ProfileWriter` can produce custom profiles that are unable to be read by `ProfileReader` (or `aot-compiler.c`). There are a few reports [here](https://github.com/xamarin/xamarin-android/issues/4602#issuecomment-618201419).
I investigated and found a cause may be the writing of incorrect string length markers in situations where `String.Length` is less than the encoded byte length. In that kind of case, the reader falls out of sync with the record structure and quickly fails. [Here is an example dependency](https://www.fuget.org/packages/AuroraControls.Core/1.2020.520.2/lib/netstandard2.0/Aurora.dll) with members that can produce the issue (I guess the odd characters are caused by obfuscation).
![image](https://user-images.githubusercontent.com/7392704/129899400-086a6e8a-373c-4601-837a-5255e7f93d82.png)
I don't think the change requires a profile format version bump, as the format itself is unchanged.
Co-authored-by: Ryan Davis <ryandavis.au@gmail.com>
-rw-r--r-- | mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileWriter.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileWriter.cs b/mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileWriter.cs index e7be91e19d6..4c202900896 100644 --- a/mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileWriter.cs +++ b/mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileWriter.cs @@ -25,8 +25,8 @@ namespace Mono.Profiler.Aot { void WriteString (string str) { - WriteInt32 (str.Length); var buf = Encoding.UTF8.GetBytes (str); + WriteInt32 (buf.Length); stream.Write (buf, 0, buf.Length); } |