check_that_malloc_is_allowed
is probably call wrongly somewhere at destruction
Summary
If a program ends while is_malloc_allowed
is set to false, the assert is triggered in the destruction phase.
Environment
- Operating System : macOS
- Architecture : Arm64
- Eigen Version : 5.0.0
- Compiler Version : Apple clang version 17.0.0 (clang-1700.3.19.1)
- Compile Flags : None
- Vector Extension : None.
Minimal Example
This issue may be related to #2958.
The following snippet:
#include <cstddef>
#define EIGEN_RUNTIME_NO_MALLOC
#include "eigen3/Eigen/Dense"
int main()
{
Eigen::internal::set_is_malloc_allowed(true);
Eigen::MatrixXd buf;
buf.resize(5,5);
Eigen::internal::set_is_malloc_allowed(false);
return EXIT_SUCCESS;
}
which worked well with Eigen 3.4.0 now fails with the assert triggered at the end of the program:
Assertion failed: (is_malloc_allowed() && "heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)"), function check_that_malloc_is_allowed, file Memory.h, line 104.
[1] 66916 abort ./a.out
Steps to reproduce
- Compile the snippet above
My line was
clang++ -std=c++20 -I ${MY_DIR}/Eigen/include snippet.cpp
- Run the program.
What is the current bug behavior?
The program crashes with
Assertion failed: (is_malloc_allowed() && "heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)"), function check_that_malloc_is_allowed, file Memory.h, line 104.
[1] 66916 abort ./a.out
What is the expected correct behavior?
Should not crash: no memory allocation occurred!