MantisBT - CMake
View Issue Details
0014801CMake(No Category)public2014-03-10 05:172016-06-10 14:31
Mathieu Malaterre 
Mathieu Malaterre 
normalminorhave not tried
closedmoved 
CMake 2.8.12.2 
 
0014801: CTest: --interactive-debug-mode 0 Debug build type (create_test_sourcelist)
For some reason I cannot get ctest to run in non interactive debug mode, the Windows Visual C++ debugger message box always appears when running tests during my continuous dashboard.

this can be seen on openjpeg dashboard, where the test is flagged as timed-out:
http://my.cdash.org/testDetails.php?test=14010787&build=579601 [^]

You could try on your side:
ctest -R random.*encode --interactive-debug-mode 0 -V

I have also prepared a small examples to reproduce:

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(heapcor)
add_executable(hc hc.cxx)
enable_testing()
add_test(NAME hc COMMAND hc)
$ cat hc.cxx
int main()
{
  char * p = new char[10];
  for( int i = 0; i < 500; ++i ) p[i] = i;
  delete p;
  return 0;
}


just run and execute.

I am attaching the output of:

ctest --interactive-debug-mode 0 -VV --debug > my.log

OS: Windows Vista Pro 32bits / Visual Studio Express 2010 / CMake 2.8.12.2
No tags attached.
log my.log (5,177) 2014-03-10 05:17
https://public.kitware.com/Bug/file/5091/my.log
Issue History
2014-03-10 05:17Mathieu MalaterreNew Issue
2014-03-10 05:17Mathieu MalaterreFile Added: my.log
2014-03-10 12:37Brad KingNote Added: 0035374
2014-03-10 13:07Mathieu MalaterreNote Added: 0035375
2014-03-10 13:21Mathieu MalaterreNote Added: 0035376
2014-03-10 13:47Brad KingNote Added: 0035378
2014-03-11 04:56Mathieu MalaterreNote Added: 0035380
2014-03-11 06:06Mathieu MalaterreNote Added: 0035381
2014-03-11 08:57Brad KingNote Added: 0035382
2014-03-11 08:57Brad KingStatusnew => resolved
2014-03-11 08:57Brad KingResolutionopen => suspended
2014-05-26 15:49Mathieu MalaterreAssigned To => Mathieu Malaterre
2014-05-26 15:49Mathieu MalaterreNote Added: 0035932
2014-05-26 15:49Mathieu MalaterreStatusresolved => feedback
2014-05-26 15:49Mathieu MalaterreResolutionsuspended => reopened
2014-05-26 16:04David ColeNote Added: 0035933
2014-05-27 02:59Mathieu MalaterreSummaryCTest: --interactive-debug-mode 0 => CTest: --interactive-debug-mode 0 Debug build type (create_test_sourcelist)
2014-05-27 03:00Mathieu MalaterreNote Added: 0035936
2014-05-27 03:00Mathieu MalaterreStatusfeedback => assigned
2014-05-27 06:06David ColeNote Added: 0035937
2014-05-27 06:09David ColeNote Edited: 0035937bug_revision_view_page.php?bugnote_id=35937#r1465
2016-06-10 14:29Kitware RobotNote Added: 0042505
2016-06-10 14:29Kitware RobotStatusassigned => resolved
2016-06-10 14:29Kitware RobotResolutionreopened => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035374)
Brad King   
2014-03-10 12:37   
I cannot reproduce this:

$ ctest --version
ctest version 3.0.0-rc1

$ ctest -C Debug -R hc
(popup appears)

$ ctest --interactive-debug-mode 0 -C Debug -R hc
(popup does not appear)

$ ctest -M Experimental -T Test -C Debug -R hc
(popup does not appear)
(0035375)
Mathieu Malaterre   
2014-03-10 13:07   
Ok, that's what I feared.

Anyway for reference on my system (Vista Pro SP2/32bits, Visual Studio Express 2010), I always get a heap corruption doing:

$ cat hc.cxx
#include <windows.h>
int main()
{
  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
  char * p = new char[10];
  for( int i = 0; i < 500; ++i ) p[i] = i;
  delete p;
  return 0;
}
$ cl hc.cxx
$ cl.exe -> NO message box

however:

$ cl /MDd hc.cxx
$ cl.exe -> message box for heap corruption appear !

Just for info, SetThreadErrorMode is not available on my system.
(0035376)
Mathieu Malaterre   
2014-03-10 13:21   
For reference, with:

$ cl /MDd hc.cxx
and
$ cl /MTd hc.cxx

I get a message box. With

$ cl /MD hc.cxx
and
$ cl /MT hc.cxx

I do not get a message box.
(0035378)
Brad King   
2014-03-10 13:47   
Re 0014801:0035376: I observe that behavior too: Debug builds get the popup without suppression, Release builds do not get the popup.

The inconsistency is that the suppression works for me.
(0035380)
Mathieu Malaterre   
2014-03-11 04:56   
Well that's odd.

For reference (tested on Win7/64bits and Win Vista Pro/32bits), anytime my project is compiled with CMAKE_BUILD_TYPE:Debug I cannot get proper behavior for --interactive-debug-mode 0. All other build type (Release RelWithDebInfo MinSizeRel) are working as expected.

I'll switch the openjpeg dashboard to use RelWithDebInfo.

You can close the issue.
(0035381)
Mathieu Malaterre   
2014-03-11 06:06   
BTW, I found other mentions of this issue:

http://stackoverflow.com/questions/14470074/how-to-ignore-windows-debug-error-dialogs-in-automated-tests [^]

Really the CRT debug report should appear on your side when compiling in Debug mode. The only way out (as documented) is:

http://msdn.microsoft.com/en-us/library/0yysf5e6.aspx [^]
(0035382)
Brad King   
2014-03-11 08:57   
Re 0014801:0035380: Okay, resolving as "suspended" pending further discoveries.
(0035932)
Mathieu Malaterre   
2014-05-26 15:49   
Here is what is missing in cmake code:

#include <crtdbg.h>

int _tmain(int argc, _TCHAR* argv[])
{
    //SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);

ref:
http://stackoverflow.com/questions/22306820/seterrormode-and-mdd-mtd-compile-flag/23853173#23853173 [^]
(0035933)
David Cole   
2014-05-26 16:04   
CMake/CTest/CPack do not need CrtSetReportMode calls in them... Your test program does.

The test program is the thing that's popping up the dialog, and then ctest is timing out because there's a dialog waiting for user input.

You should put the CrtSetReportMode calls into your test app to prevent the dialog from popping up if that's what you want to do.
(0035936)
Mathieu Malaterre   
2014-05-27 03:00   
thanks david. My initial goal is fairly simple I need to have --interactive-debug-mode 0 behave properly when building in Debug mode. In which case the patch needs to go instead in the cmake: `create_test_sourcelist` code generation.

comments ?
(0035937)
David Cole   
2014-05-27 06:06   
(edited on: 2014-05-27 06:09)
Perhaps something like this in your code before your create_test_sourcelist call:

set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
#ifdef _MSC_VER
  _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
  _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
  _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
#endif
")

(from analysis of CMake's Templates/TestDriver.cxx.in ... you may need an extra include, too)

I think it belongs in your project still, not in CMake itself. Perhaps some people want this and others don't. The popup window is very convenient for immediately notifying an interactive user that something is wrong and I would not want to suppress it in general.

(0042505)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.