New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 1471 - (Visual Studio 2015) wiseMin and cwiseMax functions crash at runtime when built in release mode
Summary: (Visual Studio 2015) wiseMin and cwiseMax functions crash at runtime when bui...
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - general Windows
: Normal Crash
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-19 21:39 UTC by Lance Chaney
Modified: 2017-09-19 21:39 UTC (History)
3 users (show)



Attachments

Description Lance Chaney 2017-09-19 21:39:38 UTC
Seems like I need an account to file a bug report, but I can't make one because registration is closed so I'm just emailing you this.

The cwiseMin and cwiseMax member functions are currently very buggy when built with the visual studio 2015 compiler. Most code using these functions will crash when compiled in release mode. According to this StackOverflow post, https://stackoverflow.com/questions/42954418/eigen-cwisemin-cwisemax-access-violation-in-visual-studio-2017-release-build/42962860, even when it doesn't crash it can produce erroneous results. 

The following code crashes when compiled with Visual Studio 2015 in release mode (both x86 and x64):

#include <Eigen\Core>
#include <iostream>

int main()
{

    Eigen::Vector3i a(1,1,1);
    Eigen::Vector3i b(10, 10, 10);

    std::cout << a.cwiseMin(b) << std::endl;

    return 0;
}

The following code only crashes when compiled with x64 release as the target:

#include <iostream>
#include <time.h>

#include <Eigen\Core>

int main() {
	int i = rand();
	Eigen::Vector3i a(i, i, i);
	Eigen::Vector3i b(10, 10, 10);
	Eigen::Vector3i min = a.cwiseMin(b);

	std::cout << min << std::endl;

	return 0;
}

Note that the above code does not crash if the variable i is replaced with a constant value.

This issue does not appear to be present with the Visual Studio 2017 compiler. This issue currently affects the open source NanoGUI widget library, which now must be compiled using Visual Studio 2017. Unfortunately, many developers are still using Visual Studio 2015 and cannot yet upgrade. See this issue report for more details: https://github.com/wjakob/nanogui/issues/258#issuecomment-329313784

Note You need to log in before you can comment on or make changes to this bug.