dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

[aot] mono_aot_split_options handles \ incorrectly #108066

Open lambdageek opened 1 hour ago

lambdageek commented 1 hour ago

The idea is that you can pass an option like --aot=foo=bar,baz="abc\"def\",xyz=012 and the AOT compiler will see options foo=bar, baz=abc"def and zyx=012.

But this line that is supposed to handle the character following a \ is wrong

https://github.com/dotnet/runtime/blob/68b90acee9d8fbc18d47dd9409a89e3ea083d1fa/src/mono/mono/mini/aot-compiler.c#L8749-L8750

it never resets the state back to MONO_AOT_OPTION_STATE_STRING, so everything after the \ until the end of the options is treated as a single long option: foo=bar, baz=abc\"def",xyz=012

Also the \ is itself never removed from the option - instead of bar=abc"def we get bar=abc\"def. (And this is a hard problem because we woudl need to copy or modify the string, which we don't otherwise do)

lambdageek commented 1 hour ago

Not a regression, this seems to go back all the way to ~2015