dotnet / runtime

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

ARM64: Fuzzlyn example Debug outputs `False` and Release outputs `True` #105413

Closed TIHan closed 1 month ago

TIHan commented 1 month ago

https://dev.azure.com/dnceng-public/public/_build/results?buildId=749360&view=logs&j=525cde17-c784-57f3-eefb-8531de9f0ec8&t=35c5a37d-2f37-53fa-c1ef-550d0a83cd34

2024-07-21T18:09:44.3808540Z ##[section]Starting: Summarize (windows arm64)
2024-07-21T18:09:44.3814219Z ==============================================================================
2024-07-21T18:09:44.3814374Z Task         : Command line
2024-07-21T18:09:44.3814442Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2024-07-21T18:09:44.3814561Z Version      : 2.237.1
2024-07-21T18:09:44.3814623Z Author       : Microsoft Corporation
2024-07-21T18:09:44.3814713Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2024-07-21T18:09:44.3814914Z ==============================================================================
2024-07-21T18:09:45.8128067Z Generating script.
2024-07-21T18:09:45.8198281Z Script contents: shell
2024-07-21T18:09:45.8203695Z D:\a\_work\1\s\venv\Scripts\python.exe D:\a\_work\1\s/src/coreclr/scripts/fuzzlyn_summarize.py -issues_directory D:\a\_work\1\s\artifacts\issues\ -arch arm64 -platform windows -build_config Checked
2024-07-21T18:09:45.8430514Z ========================== Starting Command Output ===========================
2024-07-21T18:09:45.8694751Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_work\_temp\a618fdcf-41c7-4115-a0ce-1fc142055df5.cmd""
2024-07-21T18:09:45.9924291Z # General information about run
2024-07-21T18:09:45.9924467Z * Platform: windows
2024-07-21T18:09:45.9924571Z * Architecture: arm64
2024-07-21T18:09:45.9924778Z * Build config: Checked
2024-07-21T18:09:45.9924915Z * Total programs generated: 121058
2024-07-21T18:09:45.9925030Z * Number of examples found: 1
2024-07-21T18:09:45.9925198Z * Number of known errors hit: 0
2024-07-21T18:09:45.9925251Z 
2024-07-21T18:09:45.9925413Z # 1 reduced examples are available
2024-07-21T18:09:45.9925532Z ```csharp
2024-07-21T18:09:45.9937041Z // Generated by Fuzzlyn v1.6 on 2024-07-21 17:03:21
2024-07-21T18:09:45.9937332Z // Run on Arm64 Windows
2024-07-21T18:09:45.9937447Z // Seed: 4647795495221991750
2024-07-21T18:09:45.9937632Z // Reduced from 267.0 KiB to 1.8 KiB in 00:03:16
2024-07-21T18:09:45.9937798Z // Debug: Outputs False
2024-07-21T18:09:45.9937902Z // Release: Outputs True
2024-07-21T18:09:45.9938050Z using System.Runtime.CompilerServices;
2024-07-21T18:09:45.9938110Z 
2024-07-21T18:09:45.9938234Z public class Program
2024-07-21T18:09:45.9938325Z {
2024-07-21T18:09:45.9938461Z     public static IRuntime s_rt;
2024-07-21T18:09:45.9938573Z     public static ushort[] s_14;
2024-07-21T18:09:45.9938740Z     public static bool s_23 = true;
2024-07-21T18:09:45.9938904Z     public static uint[][] s_25 = new uint[][]{new uint[]{0}};
2024-07-21T18:09:45.9939028Z     public static uint s_28;
2024-07-21T18:09:45.9939160Z     public static bool s_36;
2024-07-21T18:09:45.9939405Z     public static void Main()
2024-07-21T18:09:45.9939532Z     {
2024-07-21T18:09:45.9939669Z         CollectibleALC alc = new CollectibleALC();
2024-07-21T18:09:45.9939856Z         System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
2024-07-21T18:09:45.9940114Z         System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
2024-07-21T18:09:45.9940326Z         System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
2024-07-21T18:09:45.9940495Z         mi.Invoke(null, new object[]{System.Activator.CreateInstance(runtimeTy)});
2024-07-21T18:09:45.9940650Z     }
2024-07-21T18:09:45.9940685Z 
2024-07-21T18:09:45.9940828Z     public static void MainInner(IRuntime rt)
2024-07-21T18:09:45.9940931Z     {
2024-07-21T18:09:45.9941039Z         s_rt = rt;
2024-07-21T18:09:45.9941158Z         M45(0);
2024-07-21T18:09:45.9941243Z     }
2024-07-21T18:09:45.9941280Z 
2024-07-21T18:09:45.9941400Z     public static void M45(ushort arg0)
2024-07-21T18:09:45.9941523Z     {
2024-07-21T18:09:45.9941616Z         long var7 = default(long);
2024-07-21T18:09:45.9941755Z         for (int var0 = 0; var0 < 1; var0++)
2024-07-21T18:09:45.9942874Z         {
2024-07-21T18:09:45.9943012Z             for (int var1 = 0; var1 < 2; var1++)
2024-07-21T18:09:45.9943138Z             {
2024-07-21T18:09:45.9943229Z                 s_28 = s_25[0][0];
2024-07-21T18:09:45.9943398Z                 s_14 = new ushort[]{1};
2024-07-21T18:09:45.9943510Z                 s_rt.WriteLine("c_285", s_36);
2024-07-21T18:09:45.9943675Z                 s_rt.WriteLine("c_286", var7);
2024-07-21T18:09:45.9943797Z             }
2024-07-21T18:09:45.9943834Z 
2024-07-21T18:09:45.9943938Z             try
2024-07-21T18:09:45.9944021Z             {
2024-07-21T18:09:45.9944130Z                 arg0 = 1;
2024-07-21T18:09:45.9944218Z             }
2024-07-21T18:09:45.9944325Z             finally
2024-07-21T18:09:45.9944437Z             {
2024-07-21T18:09:45.9944525Z                 s_23 = false;
2024-07-21T18:09:45.9944662Z                 bool var8 = s_23;
2024-07-21T18:09:45.9944773Z                 s_rt.WriteLine("c_288", var8);
2024-07-21T18:09:45.9944909Z             }
2024-07-21T18:09:45.9945006Z         }
2024-07-21T18:09:46.0032194Z     }
2024-07-21T18:09:46.0032437Z }
2024-07-21T18:09:46.0032506Z 
2024-07-21T18:09:46.0032628Z public interface IRuntime
2024-07-21T18:09:46.0032777Z {
2024-07-21T18:09:46.0032916Z     void WriteLine<T>(string site, T value);
2024-07-21T18:09:46.0033061Z }
2024-07-21T18:09:46.0033105Z 
2024-07-21T18:09:46.0033239Z public class Runtime : IRuntime
2024-07-21T18:09:46.0033369Z {
2024-07-21T18:09:46.0033548Z     public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
2024-07-21T18:09:46.0033731Z }
2024-07-21T18:09:46.0033776Z 
2024-07-21T18:09:46.0033930Z public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
2024-07-21T18:09:46.0034138Z {
2024-07-21T18:09:46.0034284Z     public CollectibleALC(): base(true)
2024-07-21T18:09:46.0034419Z     {
2024-07-21T18:09:46.0034533Z     }
2024-07-21T18:09:46.0034636Z }
2024-07-21T18:09:46.0034758Z ```
2024-07-21T18:09:46.0034808Z 
2024-07-21T18:09:46.0034960Z # Run summaries per partition
2024-07-21T18:09:46.0035188Z |Partition|# Programs generated|# Examples found|# Examples with known errors|Run time|Degree of parallelism|
2024-07-21T18:09:46.0035741Z |---|---|---|---|---|---|
2024-07-21T18:09:46.0035975Z |Partition0|29571|1|0|03:00:01.7867662|2|
2024-07-21T18:09:46.0036175Z |Partition1|31035|0|0|03:00:05.7348053|2|
2024-07-21T18:09:46.0036358Z |Partition2|31296|0|0|03:00:03.5766384|2|
2024-07-21T18:09:46.0036504Z |Partition3|29156|0|0|03:00:00.9051396|2|
2024-07-21T18:09:46.0036568Z 
2024-07-21T18:09:46.0918074Z ##[error]Cmd.exe exited with code '-1'.
2024-07-21T18:09:46.1206653Z ##[section]Finishing: Summarize (windows arm64)
dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.

TIHan commented 1 month ago

This also happens on x64.

TIHan commented 1 month ago

@JulieLeeMSFT un-assigning myself as the bug is not in the emitter or codegen.

jakobbotsch commented 1 month ago

Looks like the JIT hoists the load of s_23 in the cloned finally out of the loop, even though it is written inside the loop.

jakobbotsch commented 1 month ago

Looks like another case of #54118 / #75442.