The reason is _ITERATION_DEBUG_LEVEL 2 suppose performing of numerous checks. There is working with element outside of the vector bounds that is not checked by Release mode and may cause undefined behavior.
> opencv_ml300d.dll!std::vector<int,std::allocator<int> >::operator[](unsigned int _Pos) Line 1201 C++
opencv_ml300d.dll!cv::ml::DTreesImpl::addTree(const std::vector<int,std::allocator<int> > & sidx) Line 289 C++
opencv_ml300d.dll!cv::ml::DTreesImpl::train(const cv::Ptr<cv::ml::TrainData> & trainData, int flags) Line 227 C++
opencv_test_mld.exe!CV_MLBaseTest::train(int testCaseIdx) Line 440 C++
opencv_test_mld.exe!CV_AMLTest::run_test_case(int testCaseIdx) Line 69 C++
opencv_test_mld.exe!CV_MLBaseTest::run(int __formal) Line 257 C++
opencv_test_mld.exe!cvtest::BaseTest::safe_run(int start_from) Line 221 C++
opencv_test_mld.exe!ML_DTree_regression_Test::Body() Line 126 C++
opencv_test_mld.exe!ML_DTree_regression_Test::TestBody() Line 126 C++
opencv_test_mld.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object, void (void) * method, const char * location) Line 3563 C++
opencv_test_mld.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object, void (void) * method, const char * location) Line 3614 C++
opencv_test_mld.exe!testing::Test::Run() Line 3651 C++
opencv_test_mld.exe!testing::TestInfo::Run() Line 3830 C++
opencv_test_mld.exe!testing::TestCase::Run() Line 3945 C++
opencv_test_mld.exe!testing::internal::UnitTestImpl::RunAllTests() Line 5824 C++
opencv_test_mld.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object, bool (void) * method, const char * location) Line 3563 C++
opencv_test_mld.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object, bool (void) * method, const char * location) Line 3614 C++
opencv_test_mld.exe!testing::UnitTest::Run() Line 5437 C++
opencv_test_mld.exe!RUN_ALL_TESTS() Line 20123 C++
opencv_test_mld.exe!main(int argc, char * * argv) Line 3 C++