cps-org / cps-config

A drop in replacement for pkg-config/pkgconf using cps files
MIT License
15 stars 7 forks source link

CPS_UNREACHABLE hangs #73

Open tylerjw opened 2 months ago

tylerjw commented 2 months ago

When running locally if I cause the parser to hit a CPS_UNREACHABLE macro it hangs. If I run it in gdb and break here is the stack trace:

fmt::v10::detail::buffer<char>::append<char> (this=0x7fffffffcff0, begin=0x555555598d98 "Unknown type: `{}`", end=0x555555598da7 "{}`", end@entry=0x7fffffffcff0 "x\330\367\367\377\177") at ../subprojects/fmt-10.1.1/include/fmt/format.h:872
872   while (begin != end) {
(gdb) bt
#0  fmt::v10::detail::buffer<char>::append<char> (this=0x7fffffffcff0, begin=0x555555598d98 "Unknown type: `{}`", 
    end=0x555555598da7 "{}`", end@entry=0x7fffffffcff0 "x\330\367\367\377\177") at ../subprojects/fmt-10.1.1/include/fmt/format.h:872
#1  0x00007ffff7f67963 in fmt::v10::detail::copy_str<char, char const*> (out=..., end=end@entry=0x7fffffffcff0 "x\330\367\367\377\177", 
    begin=<optimized out>) at ../subprojects/fmt-10.1.1/include/fmt/core.h:1489
#2  fmt::v10::detail::copy_str_noinline<char, char const*, fmt::v10::appender> (begin=<optimized out>, end=end@entry=0x555555598da7 "{}`", 
    out=...) at ../subprojects/fmt-10.1.1/include/fmt/format.h:645
#3  0x00007ffff7f756b7 in fmt::v10::detail::write<char, fmt::v10::appender> (value=..., out=...)
    at ../subprojects/fmt-10.1.1/include/fmt/format.h:3688
#4  fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)::format_handler::on_text(char const*, char const*) (end=0x555555598da7 "{}`", 
    begin=<optimized out>, this=0x7fffffffcf00) at ../subprojects/fmt-10.1.1/include/fmt/format.h:4348
#5  fmt::v10::detail::parse_format_string<false, char, fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)::format_handler>(fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)::format_handler&&) (handler=..., format_str=...)
    at ../subprojects/fmt-10.1.1/include/fmt/core.h:2488
#6  fmt::v10::detail::vformat_to<char> (buf=..., fmt=..., args=..., loc=..., loc@entry=...)
    at ../subprojects/fmt-10.1.1/include/fmt/format.h:4392
#7  0x00007ffff7f75f02 in fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >) (fmt=..., args=...) at ../subprojects/fmt-10.1.1/include/fmt/core.h:1534
#8  0x000055555558795e in fmt::v10::format<std::basic_string_view<char, std::char_traits<char> >&> (fmt=...)
    at ../subprojects/fmt-10.1.1/include/fmt/core.h:2788
#9  cps::loader::(anonymous namespace)::string_to_type (str=...) at ../src/cps/loader.cpp:84
#10 0x000055555558eaad in tl::detail::invoke<cps::loader::Type (&)(std::basic_string_view<char, std::char_traits<char> >), std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> (
    f=@0x5555555878a0: {cps::loader::Type (std::basic_string_view<char, std::char_traits<char> >)} 0x5555555878a0 <cps::loader::(anonymous namespace)::string_to_type(std::string_view)>)
    at /home/tyler/code/cps-config/.pixi/envs/default/x86_64-conda-linux-gnu/include/c++/12.3.0/string_view:139
#11 tl::detail::expected_map_impl<tl::expected<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, cps::loader::Type (&)(std::basic_string_view<char, std::char_traits<char> >), (void*)0, cps::loader::Type, (void*)0> (
    f=@0x5555555878a0: {cps::loader::Type (std::basic_string_view<char, std::char_traits<char> >)} 0x5555555878a0 <cps::loader::(anonymous namespace)::string_to_type(std::string_view)>, exp=...) at ../subprojects/expected-1.1.0/include/tl/expected.hpp:2104
#12 tl::expected<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::map<cps::loader::Type (&)(std::basic_string_view<char, std::char_traits<char> >)>(cps::loader::Type (&)(std::basic_string_view<char, std::char_traits<char> >)) && (
    f=@0x5555555878a0: {cps::loader::Type (std::basic_string_view<char, std::char_traits<char> >)} 0x5555555878a0 <cps::loader::(anonymous namespace)::string_to_type(std::string_view)>, this=0x7fffffffd5e0) at ../subprojects/expected-1.1.0/include/tl/expected.hpp:1342
#13 cps::loader::(anonymous namespace)::get_components (parent=..., parent_name=..., name=...) at ../src/cps/loader.cpp:211
#14 0x0000555555591681 in cps::loader::load (input_buffer=..., name=...)
    at /home/tyler/code/cps-config/.pixi/envs/default/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/char_traits.h:399
#15 0x0000555555562248 in cps::utils::test::(anonymous namespace)::Loader_minimal_package_Test::TestBody (this=<optimized out>)
    at /home/tyler/code/cps-config/.pixi/envs/default/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/basic_string.tcc:238
#16 0x00005555555801d7 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (
    location=0x5555555951d5 "the test body", method=<optimized out>, object=0x5555555bcc00)
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2612
#17 testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=object@entry=0x5555555bcc00, 
    method=<optimized out>, location=location@entry=0x5555555951d5 "the test body")
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2648
#18 0x0000555555580431 in testing::Test::Run (this=0x5555555bcc00) at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2687
#19 testing::Test::Run (this=0x5555555bcc00) at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2677
#20 0x00005555555807bf in testing::TestInfo::Run (this=0x5555555bbba0) at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2836
#21 0x000055555558388f in testing::TestSuite::Run (this=0x5555555bb7f0) at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:3015
#22 testing::TestSuite::Run (this=0x5555555bb7f0) at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2968
#23 0x0000555555587263 in testing::internal::UnitTestImpl::RunAllTests (this=0x5555555bb470)
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:5920
#24 0x0000555555580a67 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (
    location=0x5555555972f0 "auxiliary test code (environments or event listeners)", method=<optimized out>, object=0x5555555bb470)
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2612
#25 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x5555555bb470, 
    method=<optimized out>, location=location@entry=0x5555555972f0 "auxiliary test code (environments or event listeners)")
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:2648
#26 0x0000555555580c27 in testing::UnitTest::Run (this=0x5555555a8240 <testing::UnitTest::GetInstance()::instance>)
    at ../subprojects/googletest-1.14.0/googletest/src/gtest.cc:5484
#27 0x00005555555600c4 in RUN_ALL_TESTS () at ../subprojects/googletest-1.14.0/googletest/include/gtest/gtest.h:2317
#28 main (argc=<optimized out>, argv=0x7fffffffe428) at ../subprojects/googletest-1.14.0/googletest/src/gtest_main.cc:64

Looking at the code I'd expect it to print and abort the program. I don't understand why it is hanging.

tylerjw commented 2 months ago

I think this is because by default we build the assert function with the guts commented out. I don't think we should do that and failing with an error message is much friendlier to users than hanging the program.