aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-21 15:13:07 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-25 22:17:55 +0300
commit070871d97b4f6440c3f0fc647ece73b53a5837db (patch)
tree7c9d8a6c7e406568bbaa814654b2d4e0e6dcbf68
parentbf6ec74c65e1fa7542aef1cc5d46ac6104fc25ce (diff)
Use more general description for STATUS_STACK_BUFFER_OVERRUN program exit status on Windows
-rw-r--r--libbutl/process.cxx29
1 files changed, 18 insertions, 11 deletions
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index 8b558ff..4408610 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -2092,12 +2092,19 @@ namespace butl
case STATUS_DLL_INIT_FAILED: return "DLL initialization failed";
case STATUS_INTEGER_DIVIDE_BY_ZERO: return "integer divided by zero";
- // VC-compiled program that calls abort() terminates with this error code
- // (0xC0000409). That differs from MinGW GCC-compiled one, that exits
- // normally with status 3 (conforms to MSDN). Under Wine (1.9.8) such a
- // program exits with status 3 for both VC and MinGW GCC. Sounds weird.
+ // If a VC-compiled program exits with the STATUS_STACK_BUFFER_OVERRUN
+ // (0xC0000409) status, it is not necessarily because of the stack buffer
+ // overrun. This may also happen if the program called abort() due, for
+ // example, to an unhandled exception or an assertion failure (see the
+ // 'STATUS_STACK_BUFFER_OVERRUN doesn't mean that there was a stack buffer
+ // overrun' Microsoft development blog article for details). That's why we
+ // use the more general description for this error code.
//
- case STATUS_STACK_BUFFER_OVERRUN: return "stack buffer overrun";
+ // Note that MinGW GCC-compiled program exits normally with the status 3
+ // if it calls abort() (conforms to MSDN). Under Wine (1.9.8) such a
+ // behavior is common for both VC and MinGW GCC.
+ //
+ case STATUS_STACK_BUFFER_OVERRUN: return "aborted";
case STATUS_STACK_OVERFLOW: return "stack overflow";
default:
@@ -2113,13 +2120,13 @@ namespace butl
bool skip (true); // Skip leading zeros.
auto add = [&desc, &digits, &skip] (unsigned char d, bool force)
+ {
+ if (d != 0 || !skip || force)
{
- if (d != 0 || !skip || force)
- {
- desc += digits[d];
- skip = false;
- }
- };
+ desc += digits[d];
+ skip = false;
+ }
+ };
for (int i (sizeof (status) - 1); i >= 0 ; --i)
{