JochenBaier / BugInsight

A memory leak and deadlock finder for C, C++
GNU General Public License v3.0
54 stars 2 forks source link

Application was unable to start correctly #2

Open rsmz opened 3 months ago

rsmz commented 3 months ago

I tried to use BugInsight on two Qt applications and they both failed to work.

An error dialog showed the message: "The application was unable to start correctly (0x0000142). Click OK to close the application."

The command line showed this: [BugInsight] [info] BugInsight Application under test: 'MyApp.exe' [BugInsight] [info] Loading 'BugInsight' into application under test. [BugInsight] [warning] Call PeekNamedPipe() failed: 'The pipe has been ended.'.

[BugInsight] [info] Application under test finished with exit code '-1073741502'

I'm using Qt 6.2.12 and MSVC 2022.

rsmz commented 3 months ago

The errors above were with the prebuilt release, so I tried to build BugInsight and got an error following steps from https://github.com/JochenBaier/BugInsight/blob/main/Build_from_source.md

$ cmake --build . --config Release --parallel MSBuild version 17.5.1+f6fdcf537 for .NET Framework MSBUILD : error MSB1009: Project file does not exist. Switch: ALL_BUILD.vcxproj

JochenBaier commented 3 months ago

Thank you for reporting this. Testing the problem with BugInsight debug build inside VS is the best approach.

Please delete build folder and repeat the cmake steps to see if you got cmake errors. If you have *.sln open it and add you application under Debugging->Command Arguments. If you see a callstack after crash please post the crash location.

rsmz commented 2 months ago

Hello, I'm getting these compiler errors for Debug and Release:

C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(27,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(28,21): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(29,22): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(32,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,29): error C3646: '_Mtx_lock_fptr': unknown overr ide specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(128,2): message : see reference to class template in stantiation 'mutex_monitor_t' being compiled [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,31): error C3646: '_Mtx_unlock_fptr': unknown ove rride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,32): error C3646: '_Mtx_trylock_fptr': unknown ov erride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,29): error C3646: '_Cnd_wait_fptr': unknown over ride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,1): error C4430: missing type specifier - int as sumed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,31): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,45): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,36): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,50): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,29): error C3861: '_Mtx_unlock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,45): message : '_Mtx_unlock_fptr': function decla ration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight _dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,31): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,48): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,36): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,53): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,29): error C3861: '_Cnd_wait_fptr': identifier n ot found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,43): message : '_Cnd_waitfptr': function declar ation must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,126): error C2039: '_Mtx_lock_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t<f alse>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,140): error C2065: '_Mtx_lock_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,126): error C2039: '_Mtx_lock_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t<t rue>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,140): error C2065: '_Mtx_lock_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(178,128): error C2039: '_Mtx_unlock_fptr': is not a membe r of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t<f alse>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(178,144): error C2065: '_Mtx_unlock_fptr': undeclared ide ntifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(179,128): error C2039: '_Mtx_unlock_fptr': is not a membe r of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t<t rue>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(179,144): error C2065: '_Mtx_unlock_fptr': undeclared ide ntifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(180,129): error C2039: '_Mtx_trylock_fptr': is not a memb er of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t<f alse>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(180,146): error C2065: '_Mtx_trylock_fptr': undeclared id entifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(181,129): error C2039: '_Mtx_trylock_fptr': is not a memb er of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t<t rue>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(181,146): error C2065: '_Mtx_trylock_fptr': undeclared id entifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(187,126): error C2039: '_Cnd_wait_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t<f alse>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(187,140): error C2065: '_Cnd_wait_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(188,126): error C2039: '_Cnd_wait_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t<t rue>' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(188,140): error C2065: '_Cnd_wait_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] critical_section_monitor.cpp Compiling... thread_history_helper.cpp one_shot_timer.cpp leak_types.cpp memory_leak_map_with_callstack.cpp malloc_monitor.cpp _aligned_malloc_monitor.cpp strdup_monitor.cpp memory_helper.cpp heap_monitor.cpp getprocaddress_monitor.cpp local_alloc_monitor.cpp globalalloc_monitor.cpp getenvironmentvariable_monitor.cpp mutex_monitor.cpp C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(27,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(28,21): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(29,22): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(32,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,29): error C3646: '_Mtx_lock_fptr': unknown overr ide specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(128,2): message : see reference to class template in stantiation 'mutex_monitor_t' being compiled [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,31): error C3646: '_Mtx_unlock_fptr': unknown ove rride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,32): error C3646: '_Mtx_trylock_fptr': unknown ov erride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,29): error C3646: '_Cnd_wait_fptr': unknown over ride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,1): error C4430: missing type specifier - int as sumed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,31): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,45): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,36): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,50): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,29): error C3861: '_Mtx_unlock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,45): message : '_Mtx_unlock_fptr': function decla ration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight _dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,31): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,48): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,36): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,53): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,29): error C3861: '_Cnd_wait_fptr': identifier n ot found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,43): message : '_Cnd_waitfptr': function declar ation must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight dll\buginsight_dll.vcxproj]

It built the executable, but then I get this error when trying to run, and I cannot find the DLL mentioned. I used the VS2022 Command Prompt.

[BugInsight] [fatal] Needed DLL 'BugInsightDllD64.dll' not found in folder 'c:\github\BugInsight\build\Debug'. Please reinstall. Abort.

Here is the build log before the compiler errors:

MSBuild version 17.5.1+f6fdcf537 for .NET Framework

1>Checking Build System Building Custom Rule C:/github/BugInsight/buginsight/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll_mini/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll_mini2/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll/CMakeLists.txt Building Custom Rule C:/github/BugInsight/buginsight_dll/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_exe_md/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_unit_tests_md/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_lock_unit_tests_md/CMakeLists.txt main.cpp dl_main.cpp dl_main.cpp dl_main.cpp shared_settings.cpp Building Custom Rule C:/github/BugInsight/examples/example_memory_leak/CMakeLists.txt test_helper.cpp Building Custom Rule C:/github/BugInsight/examples/example_deadlock/CMakeLists.txt main.cpp test_helper.cpp main.cpp main.cpp main.cpp main.cpp test_helper.cpp test_helper.cpp Generating Code... Generating Code... buginsight_tests_leak_dll_mini.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll_mini.dll buginsight_tests_leak_dll_mini2.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll_mini2.dll Creating library C:/github/BugInsight/build/tests/buginsight_tests_leak_dll/Release/buginsight_tests_leak_dll.lib and object C:/github/BugInsight/build/tests/buginsight_tests_leak_dll/Release/buginsight_tests_leak_dll.exp example_memory_leak.vcxproj -> C:\github\BugInsight\build\Release\example_memory_leak.exe buginsight_tests_leak_dll.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll.dll test_malloc_good.cpp signal.cpp cs.cpp buginsight_tests_leak_exe_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_exe_md.exe Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_exe_load_dll/CMakeLists.txt test_aligned_malloc_good.cpp example_deadlock.vcxproj -> C:\github\BugInsight\build\Release\example_deadlock.exe main.cpp random_numbers.cpp buginsight_tests_leak_exe_load_dll.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_exe_load_dll.e xe test_critical_section_lock_order_inversion.cpp application_under_test.cpp test_localalloc_good.cpp loader.cpp test_globalalloc_good.cpp test_heapalloc_good.cpp test_critical_section_lock_order_ok_or_disabled.cpp test_strdup_good.cpp test_thread_watchdog_bad.cpp test_new_delete_good.cpp log.cpp test_winapi_good.cpp test_thread_watchdog_good.cpp test_loadlibrary_good.cpp test_std_mutex_good.cpp dll_main.cpp test_openssl_static_good.cpp command_line_parser.cpp test_std_mutex_bad.cpp test_new_delete_bad.cpp test_malloc_bad.cpp test_std_recursive_mutex_good.cpp graphcycles.cc test_std_recursive_mutex_bad.cpp test_localalloc_bad.cpp Generating Code... shared_settings.cpp test_globallalloc_bad.cpp test_heapalloc_bad.cpp test_aligned_malloc_bad.cpp deadlock_monitor.cpp test_c_file.c test_winapi_bad.cpp buginsight_tests_lock_unit_tests_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_lock_unit_tests_md .exe test_strdup_bad.cpp options_parser.cpp Generating Code... low_level_alloc.cc deadlock_monitor_api.cpp stacktrace.cc buginsight_tests_leak_unit_tests_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_unit_tests_md .exe Creating library C:/github/BugInsight/build/buginsight/Release/BugInsight.lib and object C:/github/BugInsight/buil d/buginsight/Release/BugInsight.exp Generating code thread_watchdog.cpp Finished generating code buginsight.vcxproj -> C:\github\BugInsight\build\Release\BugInsight.exe cs_mutex.cpp xxhasher.cpp log.cpp log_helper.cpp dbghelp_api.cpp iat_patching.cpp iat_helper.cpp modules_helper.cpp ldr_loader_lock.cpp patched_functions.cpp

hgyxbll commented 1 month ago

Hello, I'm getting these compiler errors for Debug and Release:

C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(27,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(28,21): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(29,22): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(32,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,29): error C3646: '_Mtx_lock_fptr': unknown overr ide specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(128,2): message : see reference to class template in stantiation 'mutex_monitor_t' being compiled [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,31): error C3646: '_Mtx_unlock_fptr': unknown ove rride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,32): error C3646: '_Mtx_trylock_fptr': unknown ov erride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,29): error C3646: '_Cnd_wait_fptr': unknown over ride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,1): error C4430: missing type specifier - int as sumed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,31): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,45): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,36): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,50): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,29): error C3861: '_Mtx_unlock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,45): message : '_Mtx_unlock_fptr': function decla ration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight _dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,31): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,48): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,36): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,53): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,29): error C3861: '_Cnd_wait_fptr': identifier n ot found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,43): message : '_Cnd_waitfptr': function declar ation must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,126): error C2039: '_Mtx_lock_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,140): error C2065: '_Mtx_lock_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,126): error C2039: '_Mtx_lock_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,140): error C2065: '_Mtx_lock_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(178,128): error C2039: '_Mtx_unlock_fptr': is not a membe r of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(178,144): error C2065: '_Mtx_unlock_fptr': undeclared ide ntifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(179,128): error C2039: '_Mtx_unlock_fptr': is not a membe r of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(179,144): error C2065: '_Mtx_unlock_fptr': undeclared ide ntifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(180,129): error C2039: '_Mtx_trylock_fptr': is not a memb er of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(180,146): error C2065: '_Mtx_trylock_fptr': undeclared id entifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(181,129): error C2039: '_Mtx_trylock_fptr': is not a memb er of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(181,146): error C2065: '_Mtx_trylock_fptr': undeclared id entifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(187,126): error C2039: '_Cnd_wait_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(176,102): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(187,140): error C2065: '_Cnd_wait_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(188,126): error C2039: '_Cnd_wait_fptr': is not a member of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(177,103): message : see declaration of 'mutex_monitor_t' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\iat\patched_functions.cpp(188,140): error C2065: '_Cnd_wait_fptr': undeclared ident ifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] critical_section_monitor.cpp Compiling... thread_history_helper.cpp one_shot_timer.cpp leak_types.cpp memory_leak_map_with_callstack.cpp malloc_monitor.cpp _aligned_malloc_monitor.cpp strdup_monitor.cpp memory_helper.cpp heap_monitor.cpp getprocaddress_monitor.cpp local_alloc_monitor.cpp globalalloc_monitor.cpp getenvironmentvariable_monitor.cpp mutex_monitor.cpp C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(27,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(28,21): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(29,22): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(32,19): error C2061: syntax error: identifier '_Thrd _result' [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,29): error C3646: '_Mtx_lock_fptr': unknown overr ide specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(128,2): message : see reference to class template in stantiation 'mutex_monitor_t' being compiled [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(39,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,31): error C3646: '_Mtx_unlock_fptr': unknown ove rride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(60,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,32): error C3646: '_Mtx_trylock_fptr': unknown ov erride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(69,1): error C4430: missing type specifier - int ass umed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,29): error C3646: '_Cnd_wait_fptr': unknown over ride specifier [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(110,1): error C4430: missing type specifier - int as sumed. Note: C++ does not support default-int [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,31): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(51,45): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,36): error C3861: '_Mtx_lock_fptr': identifier no t found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(54,50): message : '_Mtx_lock_fptr': function declara tion must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight_d ll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,29): error C3861: '_Mtx_unlock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(66,45): message : '_Mtx_unlock_fptr': function decla ration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight _dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,31): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(80,48): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,36): error C3861: '_Mtx_trylock_fptr': identifier not found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(83,53): message : '_Mtx_trylock_fptr': function decl aration must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsigh t_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,29): error C3861: '_Cnd_wait_fptr': identifier n ot found [C:\github\BugInsight\build\buginsight_dll\buginsight_dll.vcxproj] C:\github\BugInsight\buginsight_dll\api_monitors\mutex_monitor.hpp(116,43): message : '_Cnd_waitfptr': function declar ation must be available as none of the arguments depend on a template parameter [C:\github\BugInsight\build\buginsight dll\buginsight_dll.vcxproj]

It built the executable, but then I get this error when trying to run, and I cannot find the DLL mentioned. I used the VS2022 Command Prompt.

[BugInsight] [fatal] Needed DLL 'BugInsightDllD64.dll' not found in folder 'c:\github\BugInsight\build\Debug'. Please reinstall. Abort.

Here is the build log before the compiler errors:

MSBuild version 17.5.1+f6fdcf537 for .NET Framework 1>Checking Build System Building Custom Rule C:/github/BugInsight/buginsight/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll_mini/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll_mini2/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_dll/CMakeLists.txt Building Custom Rule C:/github/BugInsight/buginsight_dll/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_exe_md/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_unit_tests_md/CMakeLists.txt Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_lock_unit_tests_md/CMakeLists.txt main.cpp dl_main.cpp dl_main.cpp dl_main.cpp shared_settings.cpp Building Custom Rule C:/github/BugInsight/examples/example_memory_leak/CMakeLists.txt test_helper.cpp Building Custom Rule C:/github/BugInsight/examples/example_deadlock/CMakeLists.txt main.cpp test_helper.cpp main.cpp main.cpp main.cpp main.cpp test_helper.cpp test_helper.cpp Generating Code... Generating Code... buginsight_tests_leak_dll_mini.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll_mini.dll buginsight_tests_leak_dll_mini2.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll_mini2.dll Creating library C:/github/BugInsight/build/tests/buginsight_tests_leak_dll/Release/buginsight_tests_leak_dll.lib and object C:/github/BugInsight/build/tests/buginsight_tests_leak_dll/Release/buginsight_tests_leak_dll.exp example_memory_leak.vcxproj -> C:\github\BugInsight\build\Release\example_memory_leak.exe buginsight_tests_leak_dll.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_dll.dll test_malloc_good.cpp signal.cpp cs.cpp buginsight_tests_leak_exe_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_exe_md.exe Building Custom Rule C:/github/BugInsight/tests/buginsight_tests_leak_exe_load_dll/CMakeLists.txt test_aligned_malloc_good.cpp example_deadlock.vcxproj -> C:\github\BugInsight\build\Release\example_deadlock.exe main.cpp random_numbers.cpp buginsight_tests_leak_exe_load_dll.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_exe_load_dll.e xe test_critical_section_lock_order_inversion.cpp application_under_test.cpp test_localalloc_good.cpp loader.cpp test_globalalloc_good.cpp test_heapalloc_good.cpp test_critical_section_lock_order_ok_or_disabled.cpp test_strdup_good.cpp test_thread_watchdog_bad.cpp test_new_delete_good.cpp log.cpp test_winapi_good.cpp test_thread_watchdog_good.cpp test_loadlibrary_good.cpp test_std_mutex_good.cpp dll_main.cpp test_openssl_static_good.cpp command_line_parser.cpp test_std_mutex_bad.cpp test_new_delete_bad.cpp test_malloc_bad.cpp test_std_recursive_mutex_good.cpp graphcycles.cc test_std_recursive_mutex_bad.cpp test_localalloc_bad.cpp Generating Code... shared_settings.cpp test_globallalloc_bad.cpp test_heapalloc_bad.cpp test_aligned_malloc_bad.cpp deadlock_monitor.cpp test_c_file.c test_winapi_bad.cpp buginsight_tests_lock_unit_tests_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_lock_unit_tests_md .exe test_strdup_bad.cpp options_parser.cpp Generating Code... low_level_alloc.cc deadlock_monitor_api.cpp stacktrace.cc buginsight_tests_leak_unit_tests_md.vcxproj -> C:\github\BugInsight\build\Release\buginsight_tests_leak_unit_tests_md .exe Creating library C:/github/BugInsight/build/buginsight/Release/BugInsight.lib and object C:/github/BugInsight/buil d/buginsight/Release/BugInsight.exp Generating code thread_watchdog.cpp Finished generating code buginsight.vcxproj -> C:\github\BugInsight\build\Release\BugInsight.exe cs_mutex.cpp xxhasher.cpp log.cpp log_helper.cpp dbghelp_api.cpp iat_patching.cpp iat_helper.cpp modules_helper.cpp ldr_loader_lock.cpp patched_functions.cpp

at mutex_monitor.hpp: add below code

using _Thrd_result = int;  // add this 
using _Mtx_lock_t=_Thrd_result(__cdecl*)(_Mtx_t) noexcept;

can fix compile error

hgyxbll commented 1 month ago

I tried to use BugInsight on two Qt applications and they both failed to work.

An error dialog showed the message: "The application was unable to start correctly (0x0000142). Click OK to close the application."

The command line showed this: [BugInsight] [info] BugInsight Application under test: 'MyApp.exe' [BugInsight] [info] Loading 'BugInsight' into application under test. [BugInsight] [warning] Call PeekNamedPipe() failed: 'The pipe has been ended.'.

[BugInsight] [info] Application under test finished with exit code '-1073741502'

I'm using Qt 6.2.12 and MSVC 2022.

it crash at first below code:

// buginsight_dll\stacktrace\stacktrace.cc

TM_ATTRIBUTE_NOINLINE int GetStackFrames(void** result, unsigned long* p_hash, int p_max_depth, int p_skip_count, bool p_check)
{
// it can not use a static object, because it do not init all global and static variable.
  static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn=(RtlCaptureStackBackTrace_Function*)GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace");
  ...
}

change as

static RtlCaptureStackBackTrace_Function* RtlCaptureStackBackTrace_fn = nullptr;

TM_ATTRIBUTE_NOINLINE int GetStackFrames(void** result, unsigned long* p_hash, int p_max_depth, int p_skip_count, bool p_check)
{
  if (RtlCaptureStackBackTrace_fn==nullptr) {
    RtlCaptureStackBackTrace_fn = (RtlCaptureStackBackTrace_Function*)GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace");
  }
...
}

then it crash at second below code:

//buginsight_dll\helper\dbghelp_api.cpp
DWORD bi_symsetoptions(DWORD  SymOptions)
{
  std::lock_guard lock(g_mutex); // ---> the g_mutex is not init, when use it will crash.

  //assert(SymSetOptions_fptr);
  //return SymSetOptions_fptr(SymOptions);
  return SymSetOptions(SymOptions);
}

this is because

//buginsight_dll\dll_main.cpp
loader_t g_loader;    ------> it's constructor will call InitializeSymbolizer->dbghelp_api::bi_symsetoptions->std::lock_guard lock(g_mutex);
// but sometime g_mutex is init later than g_loader.
JochenBaier commented 1 month ago

i will take look this weekend.

hgyxbll commented 1 month ago

i will take look this weekend.

thanks. it is complex about global variable init order. I temporary change as below to run it.

// dll_main.cpp
loader_t* g_loader=nullptr;
__declspec(noinline)
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
...
  if(fdwReason == DLL_PROCESS_ATTACH || fdwReason == DLL_THREAD_ATTACH)
  {
    if(!_CRT_INIT(hinstDLL, fdwReason, lpReserved))
    {
      return(FALSE);
    }
    if (g_loader==nullptr) {
      g_loader = new loader_t();
    }
  }

  if(fdwReason == DLL_PROCESS_DETACH || fdwReason == DLL_THREAD_DETACH)
  {
    delete g_loader;
    g_loader = nullptr;
    if(!_CRT_INIT(hinstDLL, fdwReason, lpReserved))
    {
      return(FALSE);
    }
   ... 
  }

but it can not monitor global variable's memory alloc and free.

JochenBaier commented 1 month ago
  1. strange, I am not able to reproduce the "syntax error: identifier '_Thrd _result'" error. Tested with
    • Visual Studio Professional 2022 Version 17.10.5, Windows SDK Version 10.0.22621.0, Plaform Toolset v143
    • Visual Studio Community 2022 Version 17.10.5, Windows SDK Version 10.0.22621.0, Plaform Toolset v143

F12 on _Thrd_result goes with Community to C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\xthreads.h

  1. I will use your fix for RtlCaptureStackBackTrace_Function
  2. for g_mutex please test with extern: (I will rename the variable if its working):

buginsight_dll\dll_main.cpp:

std::mutex g_mutex;
loader_t g_loader;

buginsight_dll\helper\dbghelp_api.cpp: extern std::mutex g_mutex;

with this fix the order should be defined since g_mutex and g_loader are in the same translation unit

hgyxbll commented 1 month ago
  1. strange, I am not able to reproduce the "syntax error: identifier '_Thrd _result'" error. Tested with
  • Visual Studio Professional 2022 Version 17.10.5, Windows SDK Version 10.0.22621.0, Plaform Toolset v143
  • Visual Studio Community 2022 Version 17.10.5, Windows SDK Version 10.0.22621.0, Plaform Toolset v143

F12 on _Thrd_result goes with Community to C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\xthreads.h

I am use "Microsoft Visual Studio Professional 2019 Version 16.11.22, Plaform Toolset v142" _Mtx_t and _Cnd_t define at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\xthreads.h but not _Thrd_result . image

  1. for g_mutex please test with extern: (I will rename the variable if its working):

it is fixed by your solution.

Thanks.