Skip to content

Crash while parsing unsaved file #206

Open
@asandroq

Description

@asandroq

Hi,

I have a specific file that is parsed correctly when saved, but crashes irony-server when sent as unsaved content. This is the backtrace:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007efdb0d6bffb in ?? () from /usr/local/llvm-3.6/lib/libclang.so.3.6
gdb$ bt
#0  0x00007efdb0d6bffb in ?? () from /usr/local/llvm-3.6/lib/libclang.so.3.6
#1  0x00007efdb1bab654 in std::ios_base::Init::~Init (this=<optimized out>, __in_chrg=<optimized out>) at ../../../../../gcc-5.1.0/libstdc++-v3/src/c++98/ios_init.cc:136
#2  0x00007efdb06e65b1 in __run_exit_handlers (status=0x40f5e0, listp=0x7efdb0a62688 <__exit_funcs>, run_list_atexit=0x1) at exit.c:78
#3  0x00007efdb06e6635 in __GI_exit (status=<optimized out>) at exit.c:100
#4  0x00007efdb06cc774 in __libc_start_main (main=0x40a680 <main>, argc=0x4, ubp_av=0x7ffcfbfeb3e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffcfbfeb3d8) at libc-start.c:258
#5  0x0000000000404639 in _start ()

The problem seems to be in Command.cpp, line 265:

    char nl;
    std::cin.read(&nl, 1);
    if (nl != '\n') {
      std::clog << "error: missing newline for unsaved file content\n";
      return 0;
    }

I have done some debugging and it seems that, for this specific file, when unsaved, the newline is never sent to the server. Or the server somehow loses it. I cannot explain why. Moreover, the server should not crash in this situation. I don't know if the backtrace is a hint as to why the input stream loses the newline.

The file only has ASCII characters. I also tried changing the Elisp code to send another character instead of a newline, but the end result is the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions