Skip to content

JochenBaier/BugInsight

Repository files navigation

A memory leak and deadlock finder for C, C++

Introduction

BugInsight is a tool for finding memory leaks and potential deadlocks in C/C++ software for Microsoft Windows OS.

Main reason for use is to test Windows applications that cannot be tested under Linux (e.g. with AddressSanitizer, ThreadSanitizer, Valgrind) and to test the Windows only parts of an application.

An other reason is the low overhead with I/O bound (e.g. TCP/IP) applications or Qt GUI applications. A real world test with a TCP/IP application shows a slowdown of 10 %, with option "--callstacks=false" only 5 %.

BugInsight can be used manually and automated in a CI system. BugInsight does not need to be linked and no rebuilding of the application is needed.

Install

  1. Download latest release Zip BugInsight-x.x.x.x.zip from releases
  2. Unzip to any location

Usage

BugInsight.exe [Options] [Configuration] -- ["]application_to_test.exe["] [application_to_test options]

Examples:

BugInsight.exe example_memory_leak.exe 
BugInsight.exe --on_error=fail -- example_deadlock.exe
BugInsight.exe --ignore_modules=libssl-3-x64.dll,libcrypto-3-x64.dll -- app.exe --app_option

Example output memory leak detection: Example_Output
Example output deadlock detection: Example_Output

Usage in VS debugger (the VS output window will display clickable call stacks):

  1. Install VS Extension Child Process Debugging Power Tool
  2. VS project properties:
    Debugging->Command: 'path to BugInsight.exe'
    Debugging->Command Arguments: '-- $(TargetPath)'

Application under test requirements

  • C/C++ 64 bit application created with Visual Studio 2015 - 2022 (32 bit support is planned)
  • Dynamic runtime: Multi-threaded [Debug] DLL (/MD[d]), expect false positive leak reports and missing deadlocks if static runtime is used
  • For getting Calls Stacks: Debug or RelWithDebInfo configuration
  • Regression testing (CI): Release build recommended, performance could be further improved with command line option '--callstacks=false'

Features:

  • BugInsight uses (improved) parts from Visual Leak Detector for memory leak finding. The deadlock detection algorithm is from the C++ library Abseil.

  • Finding memory leaks and wrong memory API usage e.g. delete, delete[] mismatch

  • Deadlock detection and detect wrong lock usage with CriticalSection and std::mutex, std::recursive_mutex

  • Test applications (or parts of it) that cannot be tested on Linux with ThreadSanitizer and AddressSanitizer

  • Test with the Windows operating system on which the program will later run

  • Test applications that run too slowly with other test tools

  • Lock watchdog: The time a lock is waiting for a lock or holding a lock is monitored and a log or error is created if a maximum time is exceeded

  • Periodic heap validation (_heapchk(), HeapValidate())

  • Test C/C++ DLLs loaded in a Java program ( Java Native Interfaces)

  • Test C/C++ DLLs loaded in a .Net program (P/Invoke)

Monitored APIs

BugInsight can detect leaks or deadlocks from the following APIs: Monitored APIs. Please report missing APIs.
BugInsight monitors all modules (Exe ,DLL) used by application under test excluding modules provided by Windows OS (DLLs with Copyright info: 'Microsoft Corporation', e.g. Kernel32.dll).
BugInsight does not yet monitor handle leaks.

Command Line Options, Runtime API

Command Line Options
Runtime_API

Build BugInsight from source

Build_from_source

Alternatives (Windows OS)

Used Third-party software

Third-party software

License

BugInsight is licensed under the terms of the GNU General Public License v3.0 license. See LICENSE for more information.