Skip to content

Testscript reports "stack buffer overrun" when an exception is thrown. #51

@Klaim

Description

@Klaim

Context

> b --version
build2 0.12.0-a.0.7c426821e7fb
libbutl 0.12.0-a.0.69ed8e0c82e4
host x86_64-microsoft-win32-msvc14.2
Copyright (c) 2014-2019 Code Synthesis Ltd
This is free software released under the MIT license.

How To Reproduce

  1. bdep new someapp && cd someapp
  2. In someapp/someapp.cxx add the following line at the beginning of main():
    throw std::runtime_error("some error");
  3. b test

Observed

PS C:\...\someapp> b test
c++ someapp\cxx{someapp}
ld someapp\exe{someapp}
test someapp\testscript{testscript} someapp\exe{someapp}
someapp\testscript:3:1: error: someapp\someapp.exe terminated abnormally: stack buffer overrun
  info: test id: basics
  info: while testing someapp\exe{someapp}
  info: while testing dir{someapp\}
  info: while testing dir{.\}
someapp\testscript:7:1: error: someapp\someapp.exe terminated abnormally: stack buffer overrun
  info: test id: missing-name
  info: while testing someapp\exe{someapp}
  info: while testing dir{someapp\}
  info: while testing dir{.\}
info: failed to test dir{.\}

Expected

Not a stack buffer overrun report. (the "terminated abnormally" part is correct in this repro case).

Notes

  • It is not clear that the stack buffer overrun comes from build2/testscript, so it kind of lead me to first think the issue was in the program being tested.
  • In the case I first saw this issue, the program is interractive:
    • One test expects an exception to be thrown, then switch back to waiting for input - this one works (the exception is thrown and the test pass as expected);
    • Another test expects the same operation to not fail (so it should not pass - it was a work in progress) - this one fails with "stack buffer overrun";
  • That last point is surprising because if you run the same executable manually, the exception is logged but the program does not crash because it was catched (it gets back to waiting for the next input). The "stack bufferoverrun" only appear when running through testscript, even if the exception is catched (and logged through cerr).
    This might suggest an issue in the handling of cerr output stream?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions