OpenGV is a collection of computer vision methods for solving geometric vision problems. It is hosted and maintained by the Mobile Perception Lab of ShanghaiTech.
Other
1.01k
stars
354
forks
source link
fivept_kneip causes stack overflow during test_relative_pose.exe - built with Visual Studio 2019, Eigen 3.4.0 #118
The issue appears to be due to opengv::relative_pose::modules::fivept_kneip::computeBasis() in src/relative_pose/modules/fivept_kneip/code.cpp using too much stack space.
Showing a disassembly of this function below from the debugger we can see the stack pointer being adjusted at the start of the function by 196088h = 1,663,112 bytes, which is > 1 MB (default max is 1 MB). Eigen is bashing the stack with local variables for every access to groebnerMatrix due to inlining. See disassembly below (watch rsp) for the first two accesses:
factor = -groebnerMatrix(30,1); and groebnerMatrix(30,1) = 0.0; as an example.
One workaround is to increase the stack size with linker flags, e.g.:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
solves the issue for me (10 MB as an overkill, just in case, to avoid similar issues elsewhere).
The issue appears to be due to
opengv::relative_pose::modules::fivept_kneip::computeBasis()
in src/relative_pose/modules/fivept_kneip/code.cpp using too much stack space.Showing a disassembly of this function below from the debugger we can see the stack pointer being adjusted at the start of the function by 196088h = 1,663,112 bytes, which is > 1 MB (default max is 1 MB). Eigen is bashing the stack with local variables for every access to groebnerMatrix due to inlining. See disassembly below (watch rsp) for the first two accesses:
factor = -groebnerMatrix(30,1);
andgroebnerMatrix(30,1) = 0.0;
as an example.One workaround is to increase the stack size with linker flags, e.g.:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
solves the issue for me (10 MB as an overkill, just in case, to avoid similar issues elsewhere).