stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

AV in debugging_symbols::get_source_file_line_impl during app finalization

Open zlojvavan opened this issue 2 years ago • 3 comments

boost 1.81 from vcpkg on windows

"Copy Details" button in "Exception Thrown" window in VS 2022 as usually cannot open clipboard so please bear with me for bringing screenshot

image

tried to output stacktrace to stream during late destructor (apparently too late to idebug_) here's meaningful excerpt from the callstack from IDE

throw_exception_spec.exe!boost::stacktrace::detail::debugging_symbols::get_source_file_line_impl(const void * addr=0x000000013f6dd1db) Line 262 C++ throw_exception_spec.exe!boost::stacktrace::detail::debugging_symbols::to_string_impl(const void * addr=0x000000013f6dd1db, std::string & res={...}) Line 314 C++ throw_exception_spec.exe!boost::stacktrace::detail::to_string(const boost::stacktrace::frame * frames=0x0000000005cd5eb8, unsigned __int64 size=31) Line 343 C++ .... throw_exception_spec.exe!_execute_onexit_table::__l2::() Line 206 C++ throw_exception_spec.exe!__crt_seh_guarded_call::operator()<void (void),int (void) &,void (void)>(__acrt_lock_and_call::__l2::void (void) && setup=void (void){...}, _execute_onexit_table::__l2::int (void) & action=int (void){...}, __acrt_lock_and_call::__l2::void (void) && cleanup=void (void){...}) Line 204 C++ throw_exception_spec.exe!__acrt_lock_and_call<int (void)>(const __acrt_lock_id lock_id=__acrt_exit_lock, _execute_onexit_table::__l2::int (void) && action=int (void){...}) Line 974 C++ throw_exception_spec.exe!_execute_onexit_table(_onexit_table_t * table=0x000000013fd11500) Line 231 C++ throw_exception_spec.exe!common_exit::__l2::() Line 227 C++ throw_exception_spec.exe!__crt_seh_guarded_call::operator()<void (void),void (void) &,void (void)>(__acrt_lock_and_call::__l2::void (void) && setup=void (void){...}, common_exit::__l2::void (void) & action=void (void){...}, __acrt_lock_and_call::__l2::void (void) && cleanup=void (void){...}) Line 224 C++ throw_exception_spec.exe!__acrt_lock_and_call<void (void)>(const __acrt_lock_id lock_id=__acrt_exit_lock, common_exit::__l2::void (void) && action=void (void){...}) Line 974 C++ throw_exception_spec.exe!common_exit(const int return_code=0, const _crt_exit_cleanup_mode cleanup_mode=_crt_exit_full_cleanup, const _crt_exit_return_mode return_mode=_crt_exit_terminate_process) Line 259 C++ throw_exception_spec.exe!exit(int return_code=0) Line 294 C++ throw_exception_spec.exe!__scrt_common_main_seh() Line 297 C++ throw_exception_spec.exe!__scrt_common_main() Line 331 C++ throw_exception_spec.exe!mainCRTStartup(void * __formal=0x000007fffffd4000) Line 17 C++ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown

zlojvavan avatar Apr 05 '23 10:04 zlojvavan

@zlojvavan there's some workaround in https://github.com/boostorg/stacktrace/issues/148. The issues seem to be about the same OS limitation

Does the workaround help?

apolukhin avatar Feb 19 '24 08:02 apolukhin

@apolukhin not sure what is workaround there. I suppose it's just the order of static init/finit and there's not much end user can do cleanly if stacktrace lib internals finalized before his own code without author's intervening ;) sometimes I am forced to do such dirty tricks by replacing some static class instances with dynamically created ones and introducing memleak but it's better than crash during finit in my book

zlojvavan avatar Feb 20 '24 08:02 zlojvavan

Could you provide a minimal reproducer?

Also note that implementation of the library changed in latest release. Does the issue still happen on new version of the library?

apolukhin avatar Jun 10 '24 19:06 apolukhin

Updated the library in 1.85 to use the same aproach as the C++ standard library implementation. If the crash remains - it's a platform limitation

apolukhin avatar Jul 16 '24 05:07 apolukhin