-
Notifications
You must be signed in to change notification settings - Fork 473
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
odata webapi core: sehexception when using $apply=aggregate #1413
Comments
Thanks for tring our sample. I change the sample and verify that the sehexception is not from our codes. I do think it's from efcore. Because, when I change to use the in-memory data, the same aggregate expression can work. for example: But, when I switch to EFCore, it throws the sehexception. |
Thanks a lot for your help. |
@mysticdotnet That's helpful. Let's follow up the input form EFCore. Thanks. |
@xuzhg @ajcvickers can you please provide info about how to debug the underlying problem? -- see more details in https://github.com/dotnet/corefx/issues/29526#issuecomment-388932741 |
@karelz I was unable even to repro the issue. |
@karelz @ajcvickers
git clone git@github.com:OData/WebApi.git
Please let me know if it can't work at your side. |
@xuzhg that is exactly what I tried. Attached windbg to IISExpress - no exception. Even no sehexception in VS, just 502 as I posted in https://github.com/dotnet/corefx/issues/29526#issuecomment-388932741 |
Werid! It can't repo at my side now. @mysticdotnet Can you repro it? |
@xuzhg Sorry Sam, what do you mean by repo it ? |
@mysticdotnet Sorry. I mean to reproduce it. |
@xuzhg the exception occurs every time
the application is in break mode |
@karelz did you follow up @mysticdotnet 's step? |
@xuzhg I am able to repro problem (only in first F5 run in VS), but the exception is not coming from IISExpress process (nothing shows up in windbg) - see https://github.com/dotnet/corefx/issues/29526#issuecomment-388932741. |
@karelz Repro without iisexpress:
(1b40.2688): Access violation - code c0000005 (first chance) |
Can you please get a callstack from the AV? ( |
@karelz With k command i have this output now: output.txt |
@karelz @xuzhg I have more information now: 5-I change the line 80 like this: 6- Re run the app, i get another exception here: |
The stack trace above (#1413 (comment)) is missing some symbols :( |
@karelz With .symfix[+] [LocalSymbolCache] cmd, i have this output |
@karelz @xuzhg did you see the Jan analysis about this issue ? |
@xuzhg Did you expect a fix for this issue in the beta phase ? |
@mysticdotnet Sorry for later response. What do you mean beta? That's in OData side or EFCore side? |
@xuzhg I mean OData. |
@mysticdotnet Sorry, I am a little bit confusing.
|
@xuzhg I don't have more information about the root cause. Sorry for that and thank you very much |
I investigated based on data provided and information given by .NET team and we may have possible cause of the issue here. Ref: thread on EF Core repo which has more details (dotnet/efcore#12733) Particularly posting last outcome from corefx team From @jkotas The crash is caused by invalid IL generated via Reflection.Emit.
The method with invalid IL is created at this callstack:
As @divega mentioned on that thread, EF Core does not use Reflection.Emit so bad IL is not result of something in EF Core. I hand-crafted the query being created by OData for particular request. There is slight mismatch in what compiler generates vs what OData generated. var query = _context.Movies.AsNoTracking()
.GroupBy(it => new GroupByWrapper
{
GroupByContainer = new AggregationPropertyContainer.LastInChain
{
Name = "ReleaseDate",
Value = it.ReleaseDate
}
})
.Select(it => new AggregationWrapper
{
GroupByContainer = it.Key.GroupByContainer
}).ToList(); IQueryable.Expression output for both the queries.
Output of query model printer in EF Core (Query Model is generated by parsing the Expression tree using Remotion.Linq)
Based on ExpressionTree & QueryModel output, the difference is in Compiler introduce this Convert node automatically when you hand write the query. I am not sure whether it is needed or why OData is not introducing it. And what are its implication in IL. Perhaps coreFx team can provide more information on that. If current Expression Tree generated by OData is invalid (given compiler generates slightly different then) OData team can fix it. Or if the ExpressionTree is valid then it should not be generating error in IL when evaluating in memory. (perhaps corefx issue). Since EF Core is working correctly for compiler generated Expression Tree, I will be closing this issue on EF Core side. |
Any update on the fix for this issue from the OData side? |
See also: #1154 (comment) There is also #1221, which is a duplicate of this issue (been open longer, but still a duplicate) |
I´m struggling with data problem too since I can´t make a groupby. |
Im also facing this issue |
I found solution. Just change one method in AggregationBinder class private Expression WrapConvert(Expression expression)
{
return Expression.Convert(expression, typeof(object));
// return this._linqToObjectMode
// ? Expression.Convert(expression, typeof(object))
// : expression;
} Now always use convert for property |
Any updates on this? |
Hi SenyaMur, Can you give example to here please. |
What example you need? Request url or fix the bug? |
Issue should be fixed by: #1728 Could you try nightly build to check that fix works for you? |
It's worked on build 7.1.1-Nightly201907241245. |
It's worked on 7.2.0. Thank you! |
Not work on 7.3.0 :( |
Did you try to use services.AddControllers().AddNewtonsoftJson();? It seems to solve some of the issues. |
When i use $apply=aggregate with your sample (https://github.com/OData/WebApi/tree/master/samples/AspNetCoreODataSample.Web) it throw sehexception
Assemblies affected
*Microsoft.AspNetCore.OData with asp.net core
Reproduce steps
*I clone this project (https://github.com/OData/WebApi), i open this solution the odata core solution (WebApiOData.AspNetCore.sln)
and i run the sample project (https://github.com/OData/WebApi/tree/master/samples/AspNetCoreODataSample.Web)
and after i run this query: localhost:5912/odata/Movies?$apply=groupby((ReleaseDate)) *
Expected result
Show the result of the odata aggregate query
Actual result
sehexception
The text was updated successfully, but these errors were encountered: