Search Issue Tracker
Fixed in 5.3.6
Votes
0
Found in
5.3.4f1
Issue ID
796224
Regression
No
Generated C++ code using IL2CPP ignores the order of code lines in C#
When generating the Windows Store app C++ project using IL2CPP, the compiler appears to be able to ignore the order of code lines in C#, and do optimizations which effectively break the execution of certain functionality. Specifically, the issue observed is that the compiler does NOT store the value of an array item before actually "nulling" it, thus a Pop method for a stack ends up always returning null (or default value). Basically it ignores the fact that the array item is stored in a local variable, before the item at that index in the array is nulled.
Reproducible on 5.3.4f1, 5.3.5f1, 5.4.0b18.
Repro steps:
a) Launch Unity and load IL2CPP_TESTS project attached
b) Switch platform to "Universal Windows 10"
c) Switch scripting backend in Player Settings to "IL2CPP"
d) Click "Build"
e) Open up the generated C++ project (inside /bin/) in e.g. Visual Studio
f) Navigate to "Bulk_Generics_0.cpp" (may vary?) file and find lines 808 to 822 (line numbers may vary?), marked in the scope "IL_0013" (may vary?). Basically, the implementation of the Pop method of the "TestStack" class.
g) Notice how the compiled C++ code sets the array item value, before getting it, while in C# code it is the reverse. Setting it before getting it in a Pop method is devastating, because it will always return null for reference types and the default value in case of value types. The following two lines are the issue:
(L_6)->SetAt(static_cast<il2cpp_array_size_t>(L_7), (Vector3_t465617797 )L_8);
return ((L_3)->GetAt(static_cast<il2cpp_array_size_t>(L_5)));
Thus, it must assign the result of GetAt to a local variable BEFORE it calls SetAt, which effectively changes the value returned by GetAt, so that it can return the reference or value desired to the caller.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- The Editor crashes when Generating Font Atlas in the Font Asset Creator with “9999999999” padding and 256x256 Atlas Resolution
- [iOS] An “ArgumentNullException” error is thrown when GetIntroductoryPriceDictionary() method is called
- Memory leak warnings are constantly thrown when Generating Font Atlas in Font Asset Creator with 4096x8192 Atlas Resolution
- “Glyph rendering has been aborted due to sampling point size” Log is printed and Font Atlas is not generated when Atlas Resolution is 8192x8192, and the Render Mode is SDF
- Font Import Settings documentation page is missing when the documentation button is pressed in the Inspector window
Add comment