rohit-px2/nvui

Opening Chadtree results in an error

parascent opened this issue · 10 comments

Opening Chadtree causes this error for me

terminate called after throwing an instance of 'msgpack::v1::insufficient_bytes'
  what():  insufficient bytes
[1]    3544750 abort (core dumped)  

Seems like this error is popping up quite a bit (#41 #23). I believe this is occurring at msgpack::unpack when nvui attempts to deserialize the data

nvui/src/nvim.cpp

Lines 152 to 159 in a5b2b51

msg_size = stdout_pipe.read(buf, buffer_maxsize);
if (msg_size)
{
// There can be multiple messages inside of the buffer
std::size_t offset = 0;
while((std::int64_t) offset != msg_size)
{
oh = msgpack::unpack(buf, msg_size, offset);
.
Is this crash reproducible for you?

yes it happens consistently.

Okay. I'll get a fix branch up.

Could you see if #42 solves this?

still crashes on CHADopen

Application Specific Information:
abort() called
terminating with uncaught exception of type msgpack::v1::insufficient_bytes: insufficient bytes

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff203632ba mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff2036362c mach_msg + 60
2   com.apple.CoreFoundation      	0x00007fff20491b2f __CFRunLoopServiceMachPort + 316
3   com.apple.CoreFoundation      	0x00007fff2049020f __CFRunLoopRun + 1328
4   com.apple.CoreFoundation      	0x00007fff2048f61c CFRunLoopRunSpecific + 563
5   com.apple.HIToolbox           	0x00007fff286d4a83 RunCurrentEventLoopInMode + 292
6   com.apple.HIToolbox           	0x00007fff286d47e5 ReceiveNextEventCommon + 587
7   com.apple.HIToolbox           	0x00007fff286d4583 _BlockUntilNextEventMatchingListInModeWithFilter + 70
8   com.apple.AppKit              	0x00007fff22c96502 _DPSNextEvent + 864
9   com.apple.AppKit              	0x00007fff22c94cd5 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
10  com.apple.AppKit              	0x00007fff22c87049 -[NSApplication run] + 586
11  libqcocoa.dylib               	0x0000000108f287d4 0x108ef0000 + 231380
12  org.qt-project.QtCore         	0x0000000104ac8427 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 471
13  org.qt-project.QtCore         	0x0000000104acc302 QCoreApplication::exec() + 130
14  nvui                          	0x0000000103bffa5d main + 6909
15  libdyld.dylib                 	0x00007fff203b3f3d start + 1

Thread 1:
0   libsystem_kernel.dylib        	0x00007fff20363cce read + 10
1   nvui                          	0x0000000103bca4de boost::process::detail::posix::basic_pipe<char, std::__1::char_traits<char> >::read(char*, int) + 46
2   nvui                          	0x0000000103bc6a41 Nvim::read_error_sync() + 129
3   nvui                          	0x0000000103bd6ffe void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, std::__1::__bind<void (Nvim::*)(), Nvim*> > >(void*) + 62
4   libsystem_pthread.dylib       	0x00007fff203988fc _pthread_start + 224
5   libsystem_pthread.dylib       	0x00007fff20394443 thread_start + 15

Thread 2 Crashed:
0   libsystem_kernel.dylib        	0x00007fff2036992e __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff203985bd pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff202ed406 abort + 125
3   libc++abi.dylib               	0x00007fff2035bef2 abort_message + 241
4   libc++abi.dylib               	0x00007fff2034d5e5 demangling_terminate_handler() + 242
5   libobjc.A.dylib               	0x00007fff20246595 _objc_terminate() + 104
6   libc++abi.dylib               	0x00007fff2035b307 std::__terminate(void (*)()) + 8
7   libc++abi.dylib               	0x00007fff2035dbeb __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
8   libc++abi.dylib               	0x00007fff2035dbb2 __cxa_throw + 116
9   nvui                          	0x0000000103bc988b Nvim::read_output_sync() + 11515
10  nvui                          	0x0000000103bd6ffe void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, std::__1::__bind<void (Nvim::*)(), Nvim*> > >(void*) + 62
11  libsystem_pthread.dylib       	0x00007fff203988fc _pthread_start + 224
12  libsystem_pthread.dylib       	0x00007fff20394443 thread_start + 15

Thread 3:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	0x00007fff203632ba mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff2036362c mach_msg + 60
2   com.apple.CoreFoundation      	0x00007fff20491b2f __CFRunLoopServiceMachPort + 316
3   com.apple.CoreFoundation      	0x00007fff2049020f __CFRunLoopRun + 1328
4   com.apple.CoreFoundation      	0x00007fff2048f61c CFRunLoopRunSpecific + 563
5   com.apple.AppKit              	0x00007fff22e1c5ca _NSEventThread + 124
6   libsystem_pthread.dylib       	0x00007fff203988fc _pthread_start + 224
7   libsystem_pthread.dylib       	0x00007fff20394443 thread_start + 15

Thread 4:
0   libsystem_pthread.dylib       	0x00007fff20394420 start_wqthread + 0

Thread 2 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000700008285000  rcx: 0x0000700008284728  rdx: 0x0000000000000000
  rdi: 0x000000000000a30b  rsi: 0x0000000000000006  rbp: 0x0000700008284750  rsp: 0x0000700008284728
   r8: 0x00007000082845f0   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x000000000000a30b  r13: 0x0000003000000008  r14: 0x0000000000000006  r15: 0x0000000000000016
  rip: 0x00007fff2036992e  rfl: 0x0000000000000246  cr2: 0x00007fff20266ad8
  
Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133

OS: MacOS

I think I've narrowed the problem down to ext_hlstate setting. This setting gives a more semantic definition of highlight attributes and gives you the name of the highlight attribute and what it links to, which is useful for the popup menu since it looks for PMenu, PMenuSel, PMenuThumb, etc. attributes. However it looks like when you do :CHADopen and particularly when Neovim sends the highlight info, the data is incorrectly formatted and causes the program to crash.
At least, this is what is happening for me on Ubuntu.

Could you try running the program with --ext_hlstate=false @en1tan ?

crashes with this error
libc++abi: terminating with uncaught exception of type msgpack::v1::insufficient_bytes: insufficient bytes

Have you built nvui on the latest commit of the exception_insufficient_bytes branch? I'm adding commits there to fix the insufficient bytes issue.

just saw the commit, I will do that.

now works