|Summary:||Bad assertion error in debug mode and wrong result in release mode while evaluating product involving dynamic-size block|
|Component:||Core - matrix products||Assignee:||Nobody <eigen.nobody>|
|Version:||3.3 (current stable)|
|Bug Depends on:|
Description twan_koolen 2016-08-29 20:03:13 UTC
Created attachment 725 [details] Program demonstrating issue See attached program, which triggers an assertion error in debug mode. Assertion error happens when evaluating the product of a dynamically-sized block of a row vector and another matrix into a preallocated matrix (of the correct size).
Comment 1 twan_koolen 2016-08-30 12:58:36 UTC
Also, the results are wrong (with no error or crash) when compiled in release mode (compare c to d in attached program).
Comment 2 Christoph Hertzberg 2016-08-30 13:34:10 UTC
The problem is in product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, DenseShape>::coeff(Index) const where (src/Core/ProductEvaluator, line 535): const Index row = RowsAtCompileTime == 1 ? 0 : index; But in your case RowsAtCompileTime is Dynamic, so the wrong choice is made. A quick-fix would be to use MaxRowsAtCompileTime here, though I'm not entirely sure if this breaks in other situations. Btw: Strangely, it also works with d.noalias() = a_block * b; In this case the coeff(Index, Index) method of the product_evaluator is called (for reasons not obvious to me). Also, this worked in 3.2 --> block3.3
Comment 3 Gael Guennebaud 2016-08-31 06:41:03 UTC
It's rather unusual to call block on a vector. Anyway, here is a quick fix: https://bitbucket.org/eigen/eigen/commits/da70c175e484/ Let me write a full unit test before closing the bug.
Comment 4 twan_koolen 2016-08-31 06:49:09 UTC
I agree, but somebody used this in our codebase and it broke when we updated to the most recent version. Thanks for the fix!
Comment 5 Gael Guennebaud 2016-08-31 13:49:30 UTC
Sure, I was just looking for an excuse on the lack an appropriate unit test, fixed now: https://bitbucket.org/eigen/eigen/commits/3ef64b2fc7e4/ Summary: Bug 1283: add regression unit test
Comment 6 Nobody 2019-12-04 16:09:34 UTC
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1283.