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

Opening a non-existent file leads to a crash #1299

Closed
the-mikedavis opened this issue May 15, 2022 · 1 comment
Closed

Opening a non-existent file leads to a crash #1299

the-mikedavis opened this issue May 15, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@the-mikedavis
Copy link
Contributor

Describe the bug

Opening a file that does not exist crashes ErlangLS.

To work around this, one can touch the file before attempting to open it.

Based on the crash report it looks like this originated from the new shallow indexing functions introduced in #1260.

To Reproduce

Open a file that does not exist yet in your editor. This happens for me within an existing workspace like a rebar3 project but also outside of workspaces on any file. This may be difficult to reproduce in any editor that immediately writes a file when it opens it. I expect it occurs with something like vim f.erl where f.erl doesn't exist yet. In my case: hx f.erl.

Expected behavior

Mainly I would like to avoid the crash. Diagnostics for the buffer would be gravy.

Actual behavior

ErlangLS crashes and terminates leaving an erl_crash.dump.

Logs:

[2022-05-14T17:47:14.484015-05:00] [error] Generic server els_provider terminating. Reason: {{badmatch,{error,enoent}},[{els_indexing,shallow_index,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_indexing.erl\"},{line,145}]},{els_utils,lookup_document,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_utils.erl\"},{line,158}]},{els_text_synchronization,did_open,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization.erl\"},{line,52}]},{els_text_synchronization_provider,handle_request,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization_provider.erl\"},{line,25}]},{els_provider,handle_call,3,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_provider.erl\"},{line,107}]},{gen_server,try_handle_call,4,[{file,\"gen_server.erl\"},{line,721}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,750}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}. Last message: {handle_request,els_text_synchronization_provider,{did_open,#{<<\"textDocument\">> => #{<<\"languageId\">> => <<\"erlang\">>,<<\"text\">> => <<\"\\n\">>,<<\"uri\">> => <<\"file:https:///home/michael/f.erl\">>,<<\"version\">> => 0}}}}. State: #{in_progress => [],in_progress_diagnostics => []}. Client els_server stacktrace: [{gen,do_call,4,[{file,\"gen.erl\"},{line,214}]},{gen_server,call,3,[{file,\"gen_server.erl\"},{line,243}]},{els_methods,textdocument_didopen,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_methods.erl\"},{line,191}]},{els_methods,dispatch,4,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_methods.erl\"},{line,74}]}]. [gen_server:error_info/7 L949] <0.150.0>\n
[2022-05-14T17:47:14.484723-05:00] [error] crasher: initial call: els_provider:init/1, pid: <0.150.0>, registered_name: els_provider, error: {{badmatch,{error,enoent}},[{els_indexing,shallow_index,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_indexing.erl\"},{line,145}]},{els_utils,lookup_document,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_utils.erl\"},{line,158}]},{els_text_synchronization,did_open,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization.erl\"},{line,52}]},{els_text_synchronization_provider,handle_request,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization_provider.erl\"},{line,25}]},{els_provider,handle_call,3,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_provider.erl\"},{line,107}]},{gen_server,try_handle_call,4,[{file,\"gen_server.erl\"},{line,721}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,750}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}, ancestors: [els_sup,<0.136.0>], message_queue_len: 0, messages: [], links: [<0.137.0>], dictionary: [], trap_exit: true, status: running, heap_size: 28690, stack_size: 29, reductions: 3471764; neighbours: [proc_lib:crash_report/4 L525] <0.150.0>\n
[2022-05-14T17:47:14.485391-05:00] [error] Supervisor: {local,els_sup}. Context: child_terminated. Reason: {{badmatch,{error,enoent}},[{els_indexing,shallow_index,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_indexing.erl\"},{line,145}]},{els_utils,lookup_document,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_utils.erl\"},{line,158}]},{els_text_synchronization,did_open,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization.erl\"},{line,52}]},{els_text_synchronization_provider,handle_request,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization_provider.erl\"},{line,25}]},{els_provider,handle_call,3,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_provider.erl\"},{line,107}]},{gen_server,try_handle_call,4,[{file,\"gen_server.erl\"},{line,721}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,750}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}. Offender: id=els_provider,pid=<0.150.0>. [supervisor:do_restart/3 L736] <0.137.0>\n
[2022-05-14T17:47:14.485374-05:00] [error] Unexpected error [type=exit] [error={{{badmatch,{error,enoent}},[{els_indexing,shallow_index,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_indexing.erl\"},{line,145}]},{els_utils,lookup_document,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_utils.erl\"},{line,158}]},{els_text_synchronization,did_open,1,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization.erl\"},{line,52}]},{els_text_synchronization_provider,handle_request,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_text_synchronization_provider.erl\"},{line,25}]},{els_provider,handle_call,3,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_core/src/els_provider.erl\"},{line,107}]},{gen_server,try_handle_call,4,[{file,\"gen_server.erl\"},{line,721}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,750}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]},{gen_server,call,[els_provider,{handle_request,els_text_synchronization_provider,{did_open,#{<<\"textDocument\">> => #{<<\"languageId\">> => <<\"erlang\">>,<<\"text\">> => <<\"\\n\">>,<<\"uri\">> => <<\"file:https:///home/michael/f.erl\">>,<<\"version\">> => 0}}}},infinity]}}] [stack=[{gen_server,call,3,[{file,\"gen_server.erl\"},{line,247}]},{els_methods,textdocument_didopen,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_methods.erl\"},{line,191}]},{els_methods,dispatch,4,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_methods.erl\"},{line,74}]},{els_server,handle_request,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_server.erl\"},{line,162}]},{lists,foldl,3,[{file,\"lists.erl\"},{line,1267}]},{els_server,handle_cast,2,[{file,\"/build/f6zcfzjgac200djpxhsg5cs77gbz9sml-source/apps/els_lsp/src/els_server.erl\"},{line,119}]},{gen_server,try_dispatch,4,[{file,\"gen_server.erl\"},{line,695}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,771}]}]] [els_methods:dispatch/4 L79] <0.148.0>\n
[2022-05-14T17:47:14.525676-05:00] [error] Supervisor: {<0.63.0>,user_sup}. Context: child_terminated. Reason: epipe. Offender: pid=<0.64.0>,mod=user_sup. [supervisor_bridge:report_error/3 L149] <0.63.0>\n
[2022-05-14T17:47:14.525855-05:00] [error] Generic server <0.63.0> terminating. Reason: epipe. Last message: {'EXIT',<0.64.0>,epipe}. State: {state,user_sup,undefined,<0.64.0>,{<0.63.0>,user_sup}}. [gen_server:error_info/7 L949] <0.63.0>\n
[2022-05-14T17:47:14.526058-05:00] [error] crasher: initial call: supervisor_bridge:user_sup/1, pid: <0.63.0>, registered_name: [], exit: {epipe,[{gen_server,handle_common_reply,8,[{file,\"gen_server.erl\"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}, ancestors: [kernel_sup,<0.47.0>], message_queue_len: 0, messages: [], links: [<0.49.0>], dictionary: [], trap_exit: true, status: running, heap_size: 4185, stack_size: 29, reductions: 36097; neighbours: [proc_lib:crash_report/4 L525] <0.63.0>\n
[2022-05-14T17:47:14.526434-05:00] [error] Supervisor: {local,kernel_sup}. Context: child_terminated. Reason: epipe. Offender: id=user,pid=<0.63.0>. [supervisor:do_restart/3 L751] <0.49.0>\n

Context

  • erlang_ls version (tag/sha): 0.9.0-500-g2dfb48a (git describe)
  • Editor used: helix
  • LSP client used: helix's builtin LSP client

See also helix-editor/helix#2474 which includes a log of the LSP messages.

@the-mikedavis the-mikedavis added the bug Something isn't working label May 15, 2022
@the-mikedavis
Copy link
Contributor Author

the-mikedavis commented May 15, 2022

Oh whoops I was behind (I was on 4449a63). It looks like this was just fixed in #1298.

Sorry for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant