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

segfault at startup #135

Closed
qtyra opened this issue Aug 30, 2024 · 2 comments
Closed

segfault at startup #135

qtyra opened this issue Aug 30, 2024 · 2 comments

Comments

@qtyra
Copy link

qtyra commented Aug 30, 2024

Describe the bug

mesonlsp segfaults at startup when a meson.build file lacks a project call at the top and there is some other statement.

Steps To Reproduce

  1. Run mkdir /tmp/testlsp && cd /tmp/testlsp and copy this on minimal_init.lua:
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            "williamboman/mason-lspconfig.nvim",
            dependencies = { "williamboman/mason.nvim", opts = {} },
            opts = {
                ensure_installed = { "mesonlsp" },
                handlers = {
                    mesonlsp = function()
                        require("lspconfig")["mesonlsp"].setup({
                            capabilities = vim.lsp.protocol.make_client_capabilities(),
                        })
                    end,
                },
            },
        },
        {
            "neovim/nvim-lspconfig",
            config = function()
                vim.lsp.set_log_level("trace")
                require("vim.lsp.log").set_format_func(vim.inspect)
            end,
        },
    },
})
  1. Copy this in meson.build:
gtkdep = dependency('gtk+-3.0')
  1. Run nvim --clean -u minimal_init.lua meson.build, wait a few seconds until mesonlsp is installed (a message will appear at the bottom).
  2. Load the file with :e and get the error: Client mesonlsp quit with exit code 0 and signal 11. Check log for errors: ...

Expected behavior

Get Missing project() call at the top of file as normal.

System info

  • OS: Arch linux
  • Editor: Neovim
  • Version: NVIM v0.10.1

Additional context

last two messages of lsp log (github doesn't allow me to send the full message):

[ INFO ] analyze::mesontree - ../src/libanalyze/mesontree.cpp:121: Using custom parser for /tmp/testlsp/meson.build \n"
[INFO][2024-08-30 08:47:22] .../lua/vim/lsp.lua:799	"exit_handler"	{}

gdb stacktrace:

#0  0x00000000004f71cf in std::__shared_ptr<Node, (__gnu_cxx::_Lock_policy)2>::get (this=<optimized out>) at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:1666
#1  FunctionExpression::functionName[abi:cxx11]() const (this=<optimized out>) at ../src/libast/node.hpp:445
#2  getSubprojectBaseDir (tree=<synthetic pointer>: <optimized out>) at ../src/libanalyze/subprojects/subprojectstate.cpp:40
#3  SubprojectState::findSubprojects (this=0x7d79962c4118, downloadSubprojects=0x1, tree=<optimized out>) at ../src/libanalyze/subprojects/subprojectstate.cpp:67
#4  0x00000000004e3692 in SubprojectState::fullSetup (tree=0x7d79962c4010, useCustomParser=0x1, downloadSubprojects=<optimized out>, ns=..., parentIdentifier=..., depth=0x1, options=..., this=0x7d79962c4118) at ../src/libanalyze/subprojects/subprojectstate.hpp:57
#5  MesonTree::fullParse (this=0x7d79962c4010, analysisOptions=..., downloadSubprojects=<optimized out>) at ../src/libanalyze/mesontree.hpp:50
#6  0x00000000006c6187 in Workspace::parse[abi:cxx11](TypeNamespace const&) (this=0x7d79962b8010, ns=...) at ../src/liblangserver/workspace.cpp:496
#7  0x00000000006ad3f7 in LanguageServer::initialize (this=0x7d7996a2a510, params=...) at ../src/liblangserver/langserver.cpp:236
#8  0x000000000071045d in AbstractLanguageServer::handleRequest (this=0x7d7996a2a510, method=..., callId=..., params=...) at ../src/libls/ls.cpp:83
#9  0x0000000000695ff9 in std::__invoke_impl<void, void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > (__f=<optimized out>, __t=...) at /usr/include/c++/13.2.1/bits/invoke.h:74
#10 std::__invoke<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > (__fn=<optimized out>) at /usr/include/c++/13.2.1/bits/invoke.h:96
#11 std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul> (this=<optimized out>) at /usr/include/c++/13.2.1/bits/std_thread.h:292
#12 std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >::operator() (this=<optimized out>) at /usr/include/c++/13.2.1/bits/std_thread.h:299
#13 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >, void>::operator() (this=<optimized out>) at /usr/include/c++/13.2.1/future:1432
#14 std::__invoke_impl<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >, void>&> (__f=...) at /usr/include/c++/13.2.1/bits/invoke.h:61
#15 std::__invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >, void>&> (__fn=...) at /usr/include/c++/13.2.1/bits/invoke.h:116
#16 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>(), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >, void> >::_M_invoke (__functor=...) at /usr/include/c++/13.2.1/bits/std_function.h:291
#17 0x000000000068b325 in std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()>::operator() (this=<optimized out>) at /usr/include/c++/13.2.1/bits/std_function.h:591
#18 std::__future_base::_State_baseV2::_M_do_set (this=0x7d7996b57f90, __f=<optimized out>, __did_set=0x7d7996e3ef57) at /usr/include/c++/13.2.1/future:589
#19 0x0000000000d0391e in __pthread_once_full (init=0xc900a0 <__once_proxy>, control=0x7d7996b57fa8) at src/thread/pthread_once.c:22
#20 __pthread_once_full (control=0x7d7996b57fa8, init=0xc900a0 <__once_proxy>) at src/thread/pthread_once.c:11
#21 0x00000000006949a7 in __gthread_once (__func=<optimized out>, __once=<optimized out>) at /usr/include/c++/13.2.1/x86_64-alpine-linux-musl/bits/gthr-default.h:700
#22 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()>*, bool*> (__f=@0x7d7996e3ef70: (void (std::__future_base::_State_baseV2::*)(std::__future_base::_State_baseV2 * const, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()> *, bool *)) 0x68b2f0 <std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*)>, __once=...) at /usr/include/c++/13.2.1/mutex:907
#23 std::__future_base::_State_baseV2::_M_set_result (__ignore_failure=0x0, __res=..., this=<optimized out>) at /usr/include/c++/13.2.1/future:428
#24 std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<void (jsonrpc::JsonRpcHandler::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >), std::shared_ptr<jsonrpc::JsonRpcHandler>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > >, void>::_M_run (this=0x7d7996b57f90) at /usr/include/c++/13.2.1/future:1774
#25 0x0000000000ca4f6f in execute_native_thread_routine ()
#26 0x0000000000d02838 in start (p=0x7d7996e3f048) at src/thread/pthread_create.c:207
#27 0x0000000000d03d53 in __clone () at src/thread/x86_64/clone.s:22
Backtrace stopped: frame did not save the PC
quit
@JCWasmx86
Copy link
Owner

Thanks, I'm currently away from my laptop, but I will fix it tomorrow

@JCWasmx86
Copy link
Owner

It will be fixed in the next release (BTW thanks for this great issue description with nice reproduceable example and a backtrace)

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

No branches or pull requests

2 participants