[issue23314] Disabling CRT asserts in debug build
Steve Dower
report at bugs.python.org
Thu Feb 12 17:05:56 CET 2015
Steve Dower added the comment:
To be clearer (while still respecting the confidentiality agreement I'm under), previously this code would (if _DEBUG) display an assertion dialog and (regardless of _DEBUG) terminate the process:
close(fd); // succeeds, assuming a good fd
close(fd); // crashes here
This code would not display the dialog, but would still terminate:
_CrtSetReportMode(_CRT_ASSERT, 0);
close(fd);
close(fd);
This code would not display the dialog or terminate, but depends on knowing implementation details of the CRT:
if (!_PyVerify_fd(fd)) return posix_error()
res = close(fd);
if (res < 0) return posix_error()
if (!_PyVerify_fd(fd)) return posix_error()
res = close(fd);
if (res < 0) return posix_error()
Soon we'll have a safe way (including in the presence of threads) to do this:
_DONT_TERMINATE_ON_INVALID_PARAMETER_ON_THIS_THREAD
res = close(fd);
if (res < 0) return posix_error()
res = close(fd); // would have terminated, but now returns EBADF
if (res < 0) return posix_error()
_ALLOW_TERMINATE_ON_INVALID_PARAMETER_ON_THIS_THREAD
In the last case, we prevent termination but can't safely suppress the _DEBUG dialog in the same way.
SuppressCrashHandler works for its purpose, since the OS error mode is inherited by child processes. The _CrtSetReportMode setting is *not* inherited, and so it needs to be called in every child process created by tests. Maybe it's possible to add the call into every test, but I'm skeptical (especially considering the multiprocessing tests).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23314>
_______________________________________
More information about the Python-bugs-list
mailing list