Open remittor opened 3 years ago
The documentation says it is recommended to reuse the instance and no sense to create more than one instance. Source: https://github.com/JochenKalmbach/StackWalker#reusing-the-stackwalk-instance But these are fundamentally incorrect recommendations!
it is recommended to reuse the instance
no sense to create more than one instance
If, after calling the StackWalker::LoadModules, load a new DLL into the process and force the code of this DLL to raise an exception, then we will not receive a stack trace.
StackWalker::LoadModules
Example that reproduces this problem: https://github.com/remittor-pr/StackWalker/commit/2bbd898f6b79e4126d878620c2c3ded63739b438
Cases when TEST_NEW_DLL_AND_FUNC = 0
TEST_NEW_DLL_AND_FUNC = 0
Show a the callstack from inside an exception-handler: SymInit: symOptions: 530, UserName: 'Oleg' OS-Version: 6.1.7601 (Service Pack 1) 0x100-0x1 0000000140000000 \StackWalker_VC2015.exe (result : 0) PDB 0000000077B80000 \ntdll.dll (result : 0) -exported- 0000000077A60000 \kernel32.dll (result : 0) -exported- 000007FEFD700000 \KERNELBASE.dll (result : 0) -exported- 000007FEFE440000 \ADVAPI32.dll (result : 0) -exported- 000007FEFEC60000 \msvcrt.dll (result : 0) -exported- 000007FEFFE00000 \sechost.dll (result : 0) -exported- 000007FEFDD60000 \RPCRT4.dll (result : 0) -exported- 000007FEFC7B0000 \VERSION.dll (result : 0) -exported- 000007FEF8A60000 \api-ms-win-core-synch-l1-2-0.DLL (result : 0) -exported- 000007FEFD4E0000 \SspiCli.dll (result : 0) -exported- 000007FEF6170000 \dbghelp.dll (result : 0) -exported- c:\stkwlk\stackwalker-test2\main\stackwalker\stackwalker.cpp (1071): StackWalker::ShowCallstack c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (268): wmain f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (80): invoke_main f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): __scrt_common_main_seh f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): __scrt_common_main f:\dd\vctools\crt\vcstartup\src\startup\exe_wmain.cpp (17): wmainCRTStartup =====TestExceptionWalking====== c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (202): ExpTest5 c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (208): ExpTest4 c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (212): ExpTest3 c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (216): ExpTest2 c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (220): ExpTest1 c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (238): TestExceptionWalking c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (272): wmain f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (80): invoke_main f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): __scrt_common_main_seh f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): __scrt_common_main f:\dd\vctools\crt\vcstartup\src\startup\exe_wmain.cpp (17): wmainCRTStartup Exception-Handler called
Cases when TEST_NEW_DLL_AND_FUNC = 1
TEST_NEW_DLL_AND_FUNC = 1
SymInit: symOptions: 530, UserName: 'Oleg' OS-Version: 6.1.7601 (Service Pack 1) 0x100-0x1 0000000140000000 \StackWalker_VC2015.exe (result : 0) PDB 0000000077B80000 \ntdll.dll (result : 0) -exported- 0000000077A60000 \kernel32.dll (result : 0) -exported- 000007FEFD700000 \KERNELBASE.dll (result : 0) -exported- 000007FEFE440000 \ADVAPI32.dll (result : 0) -exported- 000007FEFEC60000 \msvcrt.dll (result : 0) -exported- 000007FEFFE00000 \sechost.dll (result : 0) -exported- 000007FEFDD60000 \RPCRT4.dll (result : 0) -exported- 000007FEFC7B0000 \VERSION.dll (result : 0) -exported- 000007FEF8A60000 \api-ms-win-core-synch-l1-2-0.DLL (result : 0) -exported- 000007FEFD4E0000 \SspiCli.dll (result : 0) -exported- 000007FEF6170000 \dbghelp.dll (result : 0) -exported- c:\stkwlk\stackwalker-test2\main\stackwalker\stackwalker.cpp (1071): StackWalker::ShowCallstack c:\stkwlk\stackwalker-test2\main\stackwalker\main.cpp (268): wmain f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (80): invoke_main f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): __scrt_common_main_seh f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): __scrt_common_main f:\dd\vctools\crt\vcstartup\src\startup\exe_wmain.cpp (17): wmainCRTStartup =====TestExceptionWalking====== ===== call cabinet.DllGetVersion(bad_ptr) ======= ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000007FEF9CD519F) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000007FEF9CD519F) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000007FEF9CD519F) 000007FEF9CD519F ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 0000000100000001) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 0000000100000001) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 0000000100000001) 0000000100000001 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 0000000100000001) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 0000000100000001) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 0000000100000001) 0000000100000001 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000000000012FC98) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000000000012FC98) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000000000012FC98) 000000000012FC98 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000000000012FCA8) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000000000012FCA8) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000000000012FCA8) 000000000012FCA8 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000000000012FC90) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000000000012FC90) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000000000012FC90) 000000000012FC90 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000000000012FCA0) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000000000012FCA0) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000000000012FCA0) 000000000012FCA0 ((module-name not available)): (filename not available): (function-name not available) ERROR: SymGetSymFromAddr64, GetLastError: 126 (Address: 000000000012FCB0) ERROR: SymGetLineFromAddr64, GetLastError: 126 (Address: 000000000012FCB0) ERROR: SymGetModuleInfo64, GetLastError: 1114 (Address: 000000000012FCB0) 000000000012FCB0 ((module-name not available)): (filename not available): (function-name not available) Exception-Handler called
The documentation says
it is recommended to reuse the instance
andno sense to create more than one instance
. Source: https://github.com/JochenKalmbach/StackWalker#reusing-the-stackwalk-instance But these are fundamentally incorrect recommendations!If, after calling the
StackWalker::LoadModules
, load a new DLL into the process and force the code of this DLL to raise an exception, then we will not receive a stack trace.Example that reproduces this problem: https://github.com/remittor-pr/StackWalker/commit/2bbd898f6b79e4126d878620c2c3ded63739b438
Cases when
TEST_NEW_DLL_AND_FUNC = 0
Cases when
TEST_NEW_DLL_AND_FUNC = 1