Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segmentation fault in 1.7.0 #408

Open
aumer-logiciel opened this issue Mar 19, 2024 · 8 comments
Open

segmentation fault in 1.7.0 #408

aumer-logiciel opened this issue Mar 19, 2024 · 8 comments
Labels

Comments

@aumer-logiciel
Copy link

aumer-logiciel commented Mar 19, 2024

I have a legacy application that is using the quill version 1.7.0 and is giving segmentation fault as soon as I try to log something.

My code:

ACE_INT32 main( ACE_INT32 argc, char * argv[] )
{
	//Moved in Start Server function
	////MA_20230511 - quill
	quill::Handler* file_handler = quill::file_handler("Engine-Quill.log", "a", quill::FilenameAppend::Date);

	file_handler->set_pattern(
		QUILL_STRING("On %(ascii_time) by (%(process)|%(thread)) - %(message)"), // log recorder format
		"%Y-%m-%d %H:%M:%S.%Qus",     // timestamp format
		/*quill::Timezone::GmtTime*/ quill::Timezone::LocalTime); // timestamp's timezone

	// This line sets the default logger's handler to be the new handler with the custom format string
	quill::set_default_logger_handler(file_handler);

	quill::start();

	// quill::Logger* logger = quill::get_logger();
	// logger->set_log_level(quill::LogLevel::TraceL3);

	// LOG_TRACE_L3(logger, "This is a log trace l3 example {}", 1);

	while (1) {
		sleep(1);
		printf("yo\n");
		LOG_INFO(quill::get_logger(), "yoyo");
	}
}

It crashes as soon as the first statement is executed.

yo
Segmentation fault (core dumped)

Here is the stacktrace:

libc.so.6!__strlen_sse2 (Unknown Source:0)
std::char_traits<char>::length() (\usr\include\c++\8\bits\char_traits.h:329)
fmt::v8::basic_string_view<char>::basic_string_view() (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:476)
fmt::v8::detail::write<char, fmt::v8::appender>(fmt::v8::appender out, const char * value) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\format.h:2147)
fmt::v8::detail::default_arg_formatter<char>::operator()<char const*>(fmt::v8::detail::default_arg_formatter<char> * const this, const char * value) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\format.h:2196)
fmt::v8::visit_format_arg<fmt::v8::detail::default_arg_formatter<char>, fmt::v8::basic_format_context<fmt::v8::appender, char> >(const fmt::v8::basic_format_arg<fmt::v8::basic_format_context<fmt::v8::appender, char> > & arg, fmt::v8::detail::default_arg_formatter<char> && vis) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:1615)
fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char>&, fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<std::conditional<std::is_same<fmt::v8::type_identity<char>::type, char>::value, fmt::v8::appender, std::back_insert_iterator<fmt::v8::detail::buffer<fmt::v8::type_identity<char>::type> > >::type, fmt::v8::type_identity<char>::type> >, fmt::v8::detail::locale_ref)::format_handler::on_replacement_field(int, char const*)(int id, fmt::v8::detail::format_handler * const this) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\format.h:2962)
fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char>&, fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<std::conditional<std::is_same<fmt::v8::type_identity<char>::type, char>::value, fmt::v8::appender, std::back_insert_iterator<fmt::v8::detail::buffer<fmt::v8::type_identity<char>::type> > >::type, fmt::v8::type_identity<char>::type> >, fmt::v8::detail::locale_ref)::format_handler&>(char const*, char const*, fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char>&, fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<std::conditional<std::is_same<fmt::v8::type_identity<char>::type, char>::value, fmt::v8::appender, std::back_insert_iterator<fmt::v8::detail::buffer<fmt::v8::type_identity<char>::type> > >::type, fmt::v8::type_identity<char>::type> >, fmt::v8::detail::locale_ref)::format_handler&)(const char * begin, const char * end, fmt::v8::detail::format_handler & handler) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:2591)
fmt::v8::detail::parse_format_string<false, char, fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char>&, fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<std::conditional<std::is_same<fmt::v8::type_identity<char>::type, char>::value, fmt::v8::appender, std::back_insert_iterator<fmt::v8::detail::buffer<fmt::v8::type_identity<char>::type> > >::type, fmt::v8::type_identity<char>::type> >, fmt::v8::detail::locale_ref)::format_handler>(fmt::v8::basic_string_view<char>, fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char>&, fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<std::conditional<std::is_same<fmt::v8::type_identity<char>::type, char>::value, fmt::v8::appender, std::back_insert_iterator<fmt::v8::detail::buffer<fmt::v8::type_identity<char>::type> > >::type, fmt::v8::type_identity<char>::type> >, fmt::v8::detail::locale_ref)::format_handler&&)(fmt::v8::detail::format_handler && handler, fmt::v8::basic_string_view<char> format_str) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:1788)
fmt::v8::detail::vformat_to<char>( buf, fmt::v8::basic_string_view<char> fmt, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> > args, fmt::v8::detail::locale_ref loc) (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\format.h:2988)
fmt::v8::vformat_to<std::back_insert_iterator<fmt::v8::basic_memory_buffer<char, 500ul, std::allocator<char> > >, 0>() (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:1674)
fmt::v8::format_to<std::back_insert_iterator<fmt::v8::basic_memory_buffer<char, 500ul, std::allocator<char> > >, char const*, char const*, char const*, 0>() (\home\umer\projects\third-party_dep\install\include\quill\bundled\fmt\core.h:3148)
_ZZNK5quill16PatternFormatter15FormatterHelperIKSt5tupleIJSt8functionIFPKcNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEES5_S5_S5_RKNS_16LogMacroMetadataEEESF_SF_EEE6formatERN3fmt2v819basic_memory_bufferIcLm500ESaIcEEESA_S5_S5_S5_SD_ENKUlDpT_E_clIJSF_SF_SF_EEEDaSQ_(const quill::PatternFormatter::FormatterHelper<const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > > * const this) (\home\umer\projects\third-party_dep\install\include\quill\PatternFormatter.h:123)
_ZN10invoke_hpp6invokeIRZNK5quill16PatternFormatter15FormatterHelperIKSt5tupleIJSt8functionIFPKcNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEES7_S7_S7_RKNS1_16LogMacroMetadataEEESH_SH_EEE6formatERN3fmt2v819basic_memory_bufferIcLm500ESaIcEEESC_S7_S7_S7_SF_EUlDpT_E_JRKSH_SW_SW_ELi0EEEDTclcl7forwardIT_Efp_Espcl7forwardIT0_Efp0_EEEOSX_DpOSY_(quill::PatternFormatter::FormatterHelper<const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > >::<lambda(auto:1 ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:147)
_ZN10invoke_hpp4impl10apply_implIRZNK5quill16PatternFormatter15FormatterHelperIKSt5tupleIJSt8functionIFPKcNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEES8_S8_S8_RKNS2_16LogMacroMetadataEEESI_SI_EEE6formatERN3fmt2v819basic_memory_bufferIcLm500ESaIcEEESD_S8_S8_S8_SG_EUlDpT_E_RSK_JLm0ELm1ELm2EEEEDcOT_OT0_St16integer_sequenceImJXspT1_EEE(const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > & args, quill::PatternFormatter::FormatterHelper<const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > >::<lambda(auto:1 ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:236)
_ZN10invoke_hpp5applyIRZNK5quill16PatternFormatter15FormatterHelperIKSt5tupleIJSt8functionIFPKcNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEES7_S7_S7_RKNS1_16LogMacroMetadataEEESH_SH_EEE6formatERN3fmt2v819basic_memory_bufferIcLm500ESaIcEEESC_S7_S7_S7_SF_EUlDpT_E_RSJ_EEDcOT_OT0_(const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > & args, quill::PatternFormatter::FormatterHelper<const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > >::<lambda(auto:1 ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:244)
quill::PatternFormatter::FormatterHelper<std::tuple<std::function<char const* (std::chrono::duration<long, std::ratio<1l, 1000000000l> >, char const*, char const*, char const*, quill::LogMacroMetadata const&)>, std::function<char const* (std::chrono::duration<long, std::ratio<1l, 1000000000l> >, char const*, char const*, char const*, quill::LogMacroMetadata const&)>, std::function<char const* (std::chrono::duration<long, std::ratio<1l, 1000000000l> >, char const*, char const*, char const*, quill::LogMacroMetadata const&)> > const>::format(fmt::v8::basic_memory_buffer<char, 500ul, std::allocator<char> >&, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, char const*, char const*, char const*, quill::LogMacroMetadata const&) const(const quill::PatternFormatter::FormatterHelper<const std::tuple<std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)>, std::function<char const*(std::chrono::duration<long int, std::ratio<1, 1000000000> >, char const*, char const*, char const*, const quill::LogMacroMetadata&)> > > * const this, fmt::v8::memory_buffer & memory_buffer, std::chrono::nanoseconds timestamp, const char * thread_id, const char * thread_name, const char * logger_name, const quill::LogMacroMetadata & logline_info) (\home\umer\projects\third-party_dep\install\include\quill\PatternFormatter.h:127)
quill::PatternFormatter::format<>(std::chrono::duration<long, std::ratio<1l, 1000000000l> >, char const*, char const*, char const*, quill::LogMacroMetadata const&) const(const quill::PatternFormatter * const this, std::chrono::nanoseconds timestamp, const char * thread_id, const char * thread_name, const char * logger_name, const quill::LogMacroMetadata & logline_info) (\usr\include\c++\8\bits\unique_ptr.h:345)
quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::<lambda(const auto:2& ...)>::operator()<>(const quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> > * const this) (\usr\include\c++\8\array:238)
invoke_hpp::invoke<quill::detail::LogEvent<IsBacktraceLogRecord, TLogMacroMetadata, FmtArgs>::_write_record_to_handlers(char const*, char const*, std::chrono::nanoseconds, const quill::LogMacroMetadata&) const [with bool IsBacktraceLogRecord = false; TLogMacroMetadata = main(ACE_INT32, char**)::<unnamed struct>; FmtArgs = {}]::<lambda(const auto:2& ...)>&>(quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::<lambda(const auto:2& ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:147)
invoke_hpp::impl::apply_impl<quill::detail::LogEvent<IsBacktraceLogRecord, TLogMacroMetadata, FmtArgs>::_write_record_to_handlers(char const*, char const*, std::chrono::nanoseconds, const quill::LogMacroMetadata&) const [with bool IsBacktraceLogRecord = false; TLogMacroMetadata = main(ACE_INT32, char**)::<unnamed struct>; FmtArgs = {}]::<lambda(const auto:2& ...)>&, const std::tuple<>&>(const std::tuple<> & args, quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::<lambda(const auto:2& ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:236)
invoke_hpp::apply<quill::detail::LogEvent<IsBacktraceLogRecord, TLogMacroMetadata, FmtArgs>::_write_record_to_handlers(char const*, char const*, std::chrono::nanoseconds, const quill::LogMacroMetadata&) const [with bool IsBacktraceLogRecord = false; TLogMacroMetadata = main(ACE_INT32, char**)::<unnamed struct>; FmtArgs = {}]::<lambda(const auto:2& ...)>&, const std::tuple<>&>(const std::tuple<> & args, quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::<lambda(const auto:2& ...)> & f) (\home\umer\projects\third-party_dep\install\include\quill\bundled\invoke\invoke.h:244)
quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::_write_record_to_handlers(const quill::LogMacroMetadata & log_record_metadata, std::chrono::nanoseconds log_record_timestamp, const char * thread_name, const char * thread_id, const quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> > * const this) (\home\umer\projects\third-party_dep\install\include\quill\detail\events\LogEvent.h:187)
quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::_backend_process<>(const quill::detail::BaseEvent::GetRealTsCallbackT & timestamp_callback, const quill::detail::BaseEvent::GetHandlersCallbackT & obtain_active_handlers, const char * thread_name, const char * thread_id, quill::detail::BacktraceLogRecordStorage & backtrace_log_record_storage, const quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> > * const this) (\home\umer\projects\third-party_dep\install\include\quill\detail\events\LogEvent.h:128)
quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> >::backend_process(quill::detail::BacktraceLogRecordStorage &, const char *, const char *, const quill::detail::BaseEvent::GetHandlersCallbackT &, const quill::detail::BaseEvent::GetRealTsCallbackT &) const(const quill::detail::LogEvent<false, main(ACE_INT32, char**)::<unnamed struct> > * const this, quill::detail::BacktraceLogRecordStorage & backtrace_log_record_storage, const char * thread_id, const char * thread_name, const quill::detail::BaseEvent::GetHandlersCallbackT & obtain_active_handlers, const quill::detail::BaseEvent::GetRealTsCallbackT & timestamp_callback) (\home\umer\projects\third-party_dep\install\include\quill\detail\events\LogEvent.h:86)
quill::detail::BackendWorker::_process_transit_event(quill::detail::BackendWorker * const this) (\usr\include\c++\8\bits\basic_string.h:2306)
quill::detail::BackendWorker::_main_loop(quill::detail::BackendWorker * const this) (\home\umer\projects\third-party_dep\install\include\quill\detail\backend\BackendWorker.h:585)
quill::detail::BackendWorker::run()::{lambda()#1}::operator()() const(const quill::detail::BackendWorker::<lambda()> * const __closure) (\home\umer\projects\third-party_dep\install\include\quill\detail\backend\BackendWorker.h:297)
libstdc++.so.6!execute_native_thread_routine (Unknown Source:0)
libpthread.so.0!start_thread (Unknown Source:0)
libc.so.6!clone (Unknown Source:0)

My system details are:
OS: AlmaLinux release 8.9 (Midnight Oncilla)
Compiler: g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20)

@aumer-logiciel
Copy link
Author

Hi @odygrd could you please look at this ?
Thank you!

@odygrd
Copy link
Owner

odygrd commented Mar 19, 2024

I could not reproduce on my machine.

It is not possible for that simple example to crash in 1.7.0 that would mean the library is not working at all and there were many unit tests.

It should be something related with your system or specific OS.

image

@odygrd odygrd added the v1.7 label Mar 19, 2024
@aumer-logiciel
Copy link
Author

This code is part of a huge legacy application that has a lot of other dependencies to it.
The thing is when I run it separately it works alright as well but combined with the application it crashes instantly.
In my application I have placed this code at the top of the main function so as to not affect it by other components but still it is giving me this error continuously.

@odygrd
Copy link
Owner

odygrd commented Mar 20, 2024

are you linking your own version of lib fmt in your final application ? Just a suspicion

@aumer-logiciel
Copy link
Author

I am using bundled fmt of quill @odygrd

@odygrd
Copy link
Owner

odygrd commented Mar 20, 2024

Are you also using your own libfmt outside the logger linking the whole program against?

Can you try to link the standalone example that you say it's working with the same libraries you're linking your application and see if it works ?

@HemaZ
Copy link

HemaZ commented Sep 19, 2024

I'm getting a similar issue with my tests using gtest. If i run the app standalone all is fine. but when i run the tests and start testing the app, the quill logging macros segfaults.
I'm using

  • gtest VERSION 1.8.1
  • Quill: v7.0.0
  • GCC: 11.4.0

Update.

I found that i was missing the setup part so a call to setup_quill fixed my issue.

@odygrd
Copy link
Owner

odygrd commented Sep 19, 2024

some gtest death tests are using fork(). Can you check if that is the case ? Are you using death tests?
https://github.com/odygrd/quill?tab=readme-ov-file#-caveats

Update:

I just saw the update, glad you fixed it. Just be aware of the death tests.

Also for the tests, you can just setup the logger* but never start the backend thread, this means the test will push logs to the spsc queue but never consume them, which is fine if you don't care about logs in the tests, just make sure you don't call flush_log()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants