Opened 5 years ago

Closed 4 years ago

#13529 closed Bugs (obsolete)

Symbols file for stacktrace is not loaded after deployment in Windows

Reported by: slawekwin@… Owned by:
Milestone: To Be Determined Component: None
Version: Boost 1.66.0 Severity: Problem
Keywords: stacktrace msvc Cc:

Description

When testing simplest program using boost::stacktrace built with MSVC (toolset 14.1) it works perfectly on the machine it was built on, but when deployed to a different system function names (and source files with line numbers) are not resolved.

#include "boost/stacktrace.hpp"
int main()
{
    boost::stacktrace::stacktrace stacktrace;
    std::cout << boost::stacktrace::detail::to_string(stacktrace.as_vector().data(), 
                                                      stacktrace.size()) << std::endl;
    return 0;
} 

I have debugged this and it seems that the reason is that IDebugSymbols does not load symbol file located in the directory of the executable, but only the one saved in Portable Executable header (it worked when I copied the .pdb file into the same path as it is on my development system).

I worked around this issue by creating my own IDebugSymbols instance (I copied the code creating it from frame_msvc.ipp debugging_symbols::try_init_com) and modifying the last line to add "." (current directory) to symbol search path with IDebugSymbols::AppendSymbolPath:

if (S_OK == iclient->QueryInterface(__uuidof(IDebugSymbols), idebug.to_void_ptr_ptr()))
    idebug->AppendSymbolPath(".");

This needs to be done only once during the process lifetime - it appears that the symbols paths string (or the symbols themselves) is cached, but I could not find documentation confirming it. Alternatively, the existence of "." part in the path could be checked with IDebugSymbols::GetSymbolPath during every debugging_symbols::try_init_com call. I also tested that IDebugSymbols::AppendSymbolPath checks current paths string and does not append duplicates (again could not find documentation to back this up) so it might be enough to always just try to append the "." during object initialization.

PS there is no stacktrace option in the "Component" combobox in this form.

Change History (1)

comment:1 by John Maddock, 4 years ago

Resolution: obsolete
Status: newclosed
Note: See TracTickets for help on using tickets.