Skip to content
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

Rewriting bug to do with rewriting GetAwaiter #190

Closed
lovettchris opened this issue Jun 12, 2021 · 0 comments · Fixed by #186
Closed

Rewriting bug to do with rewriting GetAwaiter #190

lovettchris opened this issue Jun 12, 2021 · 0 comments · Fixed by #186
Labels
area-binary-rewriting Issues related to binary rewriting bug Something isn't working

Comments

@lovettchris
Copy link
Member

Rewrite this method then run coyote rewrite, then run the program you will see a runtime error:

(ell) d:\Temp\CoyoteTest>dotnet D:\Temp\CoyoteTest\CoyoteTest\bin\Debug\net5.0\CoyoteTest.dll
Hello World!
Unhandled exception. System.MissingMethodException: Method not found: 'System.Runtime.CompilerServices.TaskAwaiter`1<!0> UncontrolledTaskAwaiter`1.GetAwaiter()'.
   at CoyoteTest.Program.<>c.<<TestDetectedUncontrolledGenericAwaiter>b__1_0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at CoyoteTest.Program.<>c.<TestDetectedUncontrolledGenericAwaiter>b__1_0()
   at CoyoteTest.Program.Test(Func`1 test, Configuration configuration) in D:\Temp\CoyoteTest\CoyoteTest\Program.cs:line 33
   at CoyoteTest.Program.TestDetectedUncontrolledGenericAwaiter() in D:\Temp\CoyoteTest\CoyoteTest\Program.cs:line 23
   at CoyoteTest.Program.Main(String[] args) in D:\Temp\CoyoteTest\CoyoteTest\Program.cs:line 16
using Microsoft.Coyote.SystematicTesting;
using Microsoft.Coyote;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;

namespace CoyoteTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Program p = new Program();
            p.TestDetectedUncontrolledGenericAwaiter();
            Console.WriteLine("Test complete!");
        }

        [Test]
        public void TestDetectedUncontrolledGenericAwaiter()
        {
            this.Test(async () =>
            {
                await new UncontrolledTaskAwaiter<int>();
            },
            configuration: this.GetConfiguration().WithTestingIterations(100));
        }


        protected void Test(Func<Task> test, Configuration configuration = null)
        {
            test();
        }

        protected Configuration GetConfiguration()
        {
            return Configuration.Create();
        }
        public class UncontrolledTaskAwaiter<T>
        {
            public TaskAwaiter<T> GetAwaiter() => Task.FromResult<T>(default).GetAwaiter();
        }
    }
}
@lovettchris lovettchris linked a pull request Jun 12, 2021 that will close this issue
@pdeligia pdeligia added the bug Something isn't working label Jun 17, 2021
@pdeligia pdeligia added the area-binary-rewriting Issues related to binary rewriting label Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-binary-rewriting Issues related to binary rewriting bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants