We're updating the issue view to help you get more done. 

QueryModel::Clone() will cause MainFromClause for some query's to be cloned twice, causing a crash

Description

A query model which contains a MainFromClause that shows up in a clause like Aggregate, seems to get cloned twice. For example, if you build the following QM:

from Int32[] e in TestQueryable<Int32[]>() select {[e] => Count()} => Aggregate(0, acc => (acc + Convert({[e] => Count()})))

you can see the "[e] => Count()", which is the MainFromClause, show up twice. This QM is built by re-linq and C# from the following code:

When this QM is cloned, it will cause a bomb because the MainFromClause is cloned twice (illegal).

A test case can be found here:
https://github.com/gordonwatts/Relinq/commit/06ba52ab38dbbbcaf22633a0227ab72738a58d37

A possible fix is the MainFromClause::Clone method checks to see if it has already been cloned, and decline to repeat the clone. A possible way to implement this can be found here:

https://github.com/gordonwatts/Relinq/commit/c9fb978dc2559bab2d969280e1931a2105d6d97b

This modification has been running in production for 6 months with very complex query models with lots of nesting levels.

Activity

Show:
Michael Ketting
February 6, 2018, 9:14 PM

Just a quick heads up. Didn't get this into v2.2. Sorry about that.

Assignee

Michael Ketting

Reporter

User known

Labels

Components

Fix versions

Affects versions

Priority

Normal
Configure