[build2] Test using c assert reports stack buffer overrun when failing (MSVC?)

Klaim - Joël Lamotte mjklaim at gmail.com
Tue Aug 14 14:48:28 UTC 2018


This is a minor issue, probably specific to MSVC:
when reporting a C assert failing in tests, at least with VS2017,
build2 reports a surprising "stack buffer overrun".

>From what I tested below, it looks like it's just the report that is incorrect,
VS's current assert() implementation does something special and it might be
misinterpreted. I know that it's implementation have changed in the recent
versions and does things to report more info when possible.

For example I just changed the string generated by bdep new with a library
and didn't change the test function:

PS G:\perso\experiments\bug_testfailwitherror> bdep test
c++ tests\basics\cxx{driver}@..\build-bug\bug_testfailwitherror\tests\basics\
ld ..\build-bug\bug_testfailwitherror\tests\basics\exe{driver}
test ..\build-bug\bug_testfailwitherror\tests\basics\exe{driver}
Assertion failed: o.str () == "Hello, World!\n", file
G:\perso\experiments\bug_testfailwitherror\tests\basics\driver.cxx,
line 25
error: test ..\build-bug\bug_testfailwitherror\tests\basics\exe{driver} failed
  error: G:\perso\experiments\build-bug\bug_testfailwitherror\tests\basics\driver.exe
terminated abnormally: stack buffer overrun
  info: test command line:
G:\perso\experiments\build-bug\bug_testfailwitherror\tests\basics\driver.exe
  info: while testing
..\build-bug\bug_testfailwitherror\tests\basics\exe{driver}
  info: while testing ..\build-bug\bug_testfailwitherror\tests\dir{basics\}
  info: while testing ..\build-bug\bug_testfailwitherror\dir{tests\}
  info: while testing ..\build-bug\dir{bug_testfailwitherror\}
info: failed to test ..\build-bug\dir{bug_testfailwitherror\}

When running the test driver manually:

PS G:\perso\experiments\bug_testfailwitherror> .\tests\basics\driver.exe
Assertion failed: o.str () == "Hello, World!\n", file
G:\perso\experiments\bug_testfailwitherror\tests\basics\driver.cxx,
line 25

(as expected - no stack buffer overrun)
I also launched a similar program through the VS debugger and usually
it specifies when there is a stack buffer overrun but here it doesn't.

If I replace the assert calls by a custom implementation using
std::quick_exit(EXIT_FAILURE)
and it didn't report the stack buffer overrun.

Joël



More information about the users mailing list