fpw / avitab

X-Plane plugin that displays a tablet to aid VR usage
GNU Affero General Public License v3.0
300 stars 59 forks source link

Linux: SEGV when closing PDF in Charts view #36

Closed rmuehl closed 5 years ago

rmuehl commented 5 years ago

Avitab crashes Xplane with a segmentation fault when I close a PDF (Charts) on Linux x86_64.

I compiled the latest git version (plugin and standalone). Same problem on both.

Here is a gdb backtrace of the standalone version (no debug-versions of the libs installed). I started the Prog, selected Charts, loaded the readme.pdf and closed it.

`(gdb) run 17:31:25 i: AviTab logger initialized 17:31:25 v: Main thread has id -134555712 17:31:25 v: Initializing GLFW driver... 17:31:25 v: Initializing GUI driver [New Thread 0x7ffff47a8700 (LWP 4085)] 17:31:25 v: LVGL thread has id -193296640 [New Thread 0x7ffff3fa7700 (LWP 4086)] 17:31:25 i: Loading nav data... 17:31:25 v: Couldn't load desired font, using fallback font 17:31:25 e: Couldn't load nav data: Couldn't open file: /home/users/me/X-Plane 11/Resources/default scenery/default apt dat/Earth nav data/apt.dat [Thread 0x7ffff3fa7700 (LWP 4086) exited] 17:31:25 v: Starting AviTab 0.3.15 17:31:25 i: No panel config - window only mode 17:31:25 i: Showing tablet 17:31:25 v: Creating GLFW window 'Aviator's Tablet 0.3.15', dimensions 800x480 17:31:25 v: Creating timer in thread -193296640 17:31:25 v: Creating timer in thread -193296640 17:31:25 v: Creating timer in thread -193296640 [New Thread 0x7ffff1320700 (LWP 4087)] 17:31:25 v: TileCache spawned thread -248379648 17:31:25 v: Couldn't load desired font, using fallback font 17:31:25 e: Couldn't load nav data: std::exception 17:31:31 v: Creating timer in thread -193296640 17:31:31 v: Init fitz in thread -193296640 17:31:31 i: Loading '/home/users/me/avitab/avitab/build/charts/readme.pdf in thread -193296640' 17:31:31 v: Document has 1 pages 17:31:31 i: Document loaded [New Thread 0x7ffff3fa7700 (LWP 4091)] 17:31:31 v: TileCache spawned thread -201689344 17:31:31 v: Couldn't load desired font, using fallback font 17:31:31 v: Loading page 0 in thread -201689344 17:31:31 v: Page 0 rasterized 17:31:33 v: TileCache ending thread -201689344 [Thread 0x7ffff3fa7700 (LWP 4091) exited] 17:31:33 v: Destroying timer in thread -193296640

Thread 2 "AviTab-standalo" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff47a8700 (LWP 4085)] 0x000000000045051e in std::__shared_ptr<avitab::App, (__gnu_cxx::_Lock_policy)2>::get() const () (gdb) bt

0 0x000000000045051e in std::__shared_ptr<avitab::App, (__gnu_cxx::_Lock_policy)2>::get() const ()

1 0x000000000044fc72 in std::shared_ptr_access<avitab::App, (gnu_cxx::_Lock_policy)2, false, false>::_M_get() const ()

2 0x000000000044f382 in std::shared_ptr_access<avitab::App, (gnu_cxx::_Lock_policy)2, false, false>::operator->() const ()

3 0x000000000048652e in avitab::ChartsApp::onSelect(std::vector<platform::DirEntry, std::allocator > const&, unsigned long)::{lambda()#1}::operator()() const ()

4 0x0000000000486be5 in std::_Function_handler<void (), avitab::ChartsApp::onSelect(std::vector<platform::DirEntry, std::allocator > const&, unsigned long)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()

5 0x000000000041d1ce in std::function<void ()>::operator()() const ()

6 0x0000000000470944 in avitab::App::exit()::{lambda()#1}::operator()() const ()

7 0x0000000000470acb in std::_Function_handler<void (), avitab::App::exit()::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()

8 0x000000000041d1ce in std::function<void ()>::operator()() const ()

9 0x0000000000440ef2 in avitab::LVGLToolkit::guiLoop() ()

10 0x0000000000442c88 in void std::__invoke_impl<void, void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit>(std::__invoke_memfun_deref, void (avitab::LVGLToolkit::&&)(), avitab::LVGLToolkit&&) ()

11 0x0000000000442466 in std::__invoke_result<void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit>::type std::__invoke<void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit>(void (avitab::LVGLToolkit::&&)(), avitab::LVGLToolkit&&) ()

12 0x0000000000443fa3 in decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) ()

13 0x0000000000443f25 in std::thread::_Invoker<std::tuple<void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit> >::operator()() ()

14 0x0000000000443ec4 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (avitab::LVGLToolkit::)(), avitab::LVGLToolkit> > >::_M_run() ()

15 0x00007ffff744538f in ?? () from /usr/lib64/libstdc++.so.6

16 0x00007ffff7713569 in start_thread () from /lib64/libpthread.so.0

17 0x00007ffff69469ef in clone () from /lib64/libc.so.6

(gdb) quit `

fpw commented 5 years ago

Thanks for the detailed report! I wasn't able to reproduce this, but the backtrace led me to a suspicion.

I pushed a change to the master, could you please try if that fixes the problem?

rmuehl commented 5 years ago

That fixed the problem with the charts.

Found out, that the Aircraft App has the same problem.

fpw commented 5 years ago

Thanks for the test. I now understand the root cause and will fix similar locations in the code.

rmuehl commented 5 years ago

Thanks a lot.

fpw commented 5 years ago

The occurence in the aircraft app was actually the only remaining location, I've fixed it on the master as well now. If you find any other problem, please open a new ticket.

Thanks again and sorry about the crashes!

rmuehl commented 5 years ago

Works perfect now.

Thanks, and keep on your cool project.