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

[Error] The active test run was aborted. Reason: Test host process crashed : Stack overflow #71

Closed
orifn1 opened this issue Mar 6, 2024 · 17 comments · Fixed by #136
Closed
Labels
bug Something isn't working
Milestone

Comments

@orifn1
Copy link

orifn1 commented Mar 6, 2024

Reqnroll Version

1.0.1

Which test runner are you using?

MSTest

Test Runner Version Number

3.0.2

.NET Implementation

.NET 7.0

Test Execution Method

Visual Studio Test Explorer

Content of reqnroll.json configuration file

{
"$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",

"trace": {
"stepDefinitionSkeletonStyle": "RegexAttribute"
}
}

Issue Description

[3/6/2024 1:15:42.005 PM] [Error] The active test run was aborted. Reason: Test host process crashed : Stack overflow.
   at Reqnroll.Bindings.AsyncMethodHelper.IsTaskOfT(System.Type, System.Type ByRef)
   at Reqnroll.Bindings.AsyncMethodHelper.IsAwaitableOfT(System.Type, System.Type ByRef)
   at Reqnroll.Bindings.AsyncMethodHelper.GetAwaitableReturnType(Reqnroll.Bindings.Reflection.IBindingMethod)
   at Reqnroll.Bindings.StepArgumentTypeConverter.CanConvert(Reqnroll.Bindings.IStepArgumentTransformationBinding, System.Object, Reqnroll.Bindings.Reflection.IBindingType)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<>c__DisplayClass5_0.<GetMatchingStepTransformation>b__0(Reqnroll.Bindings.IStepArgumentTransformationBinding)
   at System.Linq.Enumerable+WhereListIterator`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ToArray()
   at Reqnroll.Bindings.StepArgumentTypeConverter.GetMatchingStepTransformation(System.Object, Reqnroll.Bindings.Reflection.IBindingType, Boolean)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.ConvertAsync(System.Object, Reqnroll.Bindings.Reflection.IBindingType, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.DoTransformAsync(Reqnroll.Bindings.IStepArgumentTransformationBinding, System.Object, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.ConvertAsync(System.Object, Reqnroll.Bindings.Reflection.IBindingType, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.DoTransformAsync(Reqnroll.Bindings.IStepArgumentTransformationBinding, System.Object, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.ConvertAsync(System.Object, Reqnroll.Bindings.Reflection.IBindingType, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.DoTransformAsync(Reqnroll.Bindings.IStepArgumentTransformationBinding, System.Object, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.ConvertAsync(System.Object, Reqnroll.Bindings.Reflection.IBindingType, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<DoTransformAsync>d__7, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<DoTransformAsync>d__7 ByRef)
   at Reqnroll.Bindings.StepArgumentTypeConverter.DoTransformAsync(Reqnroll.Bindings.IStepArgumentTransformationBinding, System.Object, System.Globalization.CultureInfo)
   at Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Reqnroll.Bindings.StepArgumentTypeConverter+<ConvertAsync>d__6, Reqnroll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=611ce36403091019]](<ConvertAsync>d__6 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Reqnroll.Bindings.StepA

Steps to Reproduce

just run existing test(migrated from Specflow)

Link to Repro Project

No response

@orifn1 orifn1 added the bug Something isn't working label Mar 6, 2024
@gasparnagy
Copy link
Contributor

@orifn1 Could you please share what [StepArgumentTransformation]s do you have in that project?

It seems to be similar what @kaylumah reported at kaylumah/hosting#552 (comment)

@orifn1
Copy link
Author

orifn1 commented Mar 6, 2024

I have a lot - 41

  [StepArgumentTransformation(@"^examples.(\S+)\s*[or]*\s*(\S*)")]
  public string ChangeParameterInBackground(string param, string defaultValue)
  {
      return _scenarioContext.ScenarioInfo.Arguments.Contains(param)
          ? (string)_scenarioContext.ScenarioInfo.Arguments[param]
          : defaultValue;
  }

with 'null' value:

  [StepArgumentTransformation(@"^(\<null\>)$")]
  public decimal? NullStringNullTransformerDecimal(string key)
  {
      return null;
  }

@gasparnagy
Copy link
Contributor

@orifn1 The ones with string return type might be the tricky ones. Can you temporarily comment these ones out and rerun (obviously the tests will fail, but hopefully not with a stack overflow.

I will also check it, but I can do it only tomorrow.

@orifn1
Copy link
Author

orifn1 commented Mar 6, 2024

It has not helped, I commented out both
but the other 39 StepArgumentTransformation were not commented)

@kaylumah
Copy link

kaylumah commented Mar 6, 2024

@orifn1 do you have a link to the repo containing all these transformations? there might be other problematic ones.

For me it was StepTransformation from string to string; but Table transformation to objects is working

@orifn1
Copy link
Author

orifn1 commented Mar 6, 2024

no, there is no public repo

I commented out several StepTransformations, and some tests passed, but not all. So, I believe it is a bug that should be fixed

@orifn1
Copy link
Author

orifn1 commented Mar 7, 2024

looks like this code is source of the problem:
image
Unfortunately, I can't build reqnroll solution locally for now because I have problems with the framework version and do not have enough time to fix it

@gasparnagy
Copy link
Contributor

looks like this code is source of the problem

How did you figure that out? (It might be relevant for the fix as well.)

@orifn1
Copy link
Author

orifn1 commented Mar 7, 2024

I am not aware, I just investigated stack trace)

@orifn1
Copy link
Author

orifn1 commented Mar 11, 2024

looks like this code is source of the problem

How did you figure that out? (It might be relevant for the fix as well.)

you were right - the problem in this transformation

 [StepArgumentTransformation]
  public string CustomStringToStringTransformer(string str)
  {
      if (NullValueRegex.IsMatch(str))
      {
          return null;
      }

      return TryReplaceBodyPattern(str, _domainContext);
  }

this method returned it recursively because check CanConvert

image

I will try to handle it with your suggestion in the mentioned issue
SpecFlowOSS/SpecFlow#2561

@gasparnagy
Copy link
Contributor

@orifn1 thank you for looking into that. I didn't even remember that I made that comment. :) If you come up with any good workaround, please post it here.

@kaylumah
Copy link

kaylumah commented Mar 11, 2024

Interessting, that is very similar conversion (so probably same issue)

[StepArgumentTransformation]
public static string ToNullableString(string value)
{
   return Constants.NullIndicator.Equals(value, System.StringComparison.Ordinal) ? null : value;
}

Never knew that string -> string was not supported;
Is that something changed between V3 / V4 (on which Reenrol is based) or did it work by accident on V3?

@gasparnagy
Copy link
Contributor

No this is a regression in SpecFlow v3->v4 or in the Reqnroll porting (unfortunately I had to touch the converters, so it can happen that it was reintroduced during the forking). :(

@gasparnagy
Copy link
Contributor

If any of you could make a simple check with SpecFlow v4-beta to see if the regression was already present there, it would help the investigation.

@orifn1
Copy link
Author

orifn1 commented Mar 20, 2024

I have created a very small workaround to fix the stack overflow issue but can not push it into the repo because I do not have access
I just skip transformation if it was applied previously
It is not the best solution but it works)
image

@gasparnagy
Copy link
Contributor

@orifn1 thx. I will try to integrate this to the codebase next week.

@adrichem
Copy link

I'm also running into this issue, this transform reproduces it. For us its a blocker to migrate away from SpecFlow.

//Replaces placeholders in the input with correct run time values.  
[StepArgumentTransformation]
public string Transform(string input) => Parser.Parse(input);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants