torture.cpp 717 B

1234567891011121314151617181920212223242526
  1. // Copyright Antony Polukhin, 2018.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // This file tests for memory leaks. Some of the backtrace implementations
  7. // consume memory for internal needs and incorrect usage of those implementations
  8. // could lead to segfaults. Sanitizers do not detect such misuse, but this
  9. // test and `top` does.
  10. #include <boost/stacktrace.hpp>
  11. #include <iostream>
  12. #include "test_impl.hpp"
  13. int main() {
  14. int result = 0;
  15. for (unsigned i = 0; i < 10000000; ++i) {
  16. result += make_some_stacktrace1()[0].source_line();
  17. }
  18. std::cerr << "OK\nLines count " << result;
  19. }