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

LLVM conflict with Gallium3D (swrast) driver #19606

Closed
barche opened this issue Dec 15, 2016 · 4 comments · Fixed by #25597
Closed

LLVM conflict with Gallium3D (swrast) driver #19606

barche opened this issue Dec 15, 2016 · 4 comments · Fixed by #25597

Comments

@barche
Copy link
Contributor

barche commented Dec 15, 2016

The Gallium 3D driver (swrast) uses llvm to compile shaders. Running e.g. a QML application from within Julia causes a segfault (backtrace at the end of this post).

I added a package that reproduces the problem fairly easily:
https://github.com/barche/LoadQML.jl

The problem was confirmed in VirtualBox running Ubuntu 16.04 with the official 0.5 binary and on Fedora 25 using the distribution julia 0.5. The problem goes away when disabling the llvmpipe driver. The exact same C++ code works with the llvmpipe driver when loading the same QML in a standalone app (in the deps/usr/bin directory of the LoadQML package), so using llvm only in Gallium3D or only in Julia is fine.

I'm not sure if the cause here is Julia, Gallium3D or LLVM itself.

Thread 1 "julia" received signal SIGSEGV, Segmentation fault.
0x00007ffff4630add in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /usr/bin/../lib64/libstdc++.so.6
(gdb) bt
#0  0x00007ffff4630add in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /usr/bin/../lib64/libstdc++.so.6
#1  0x00007ffff4630ea9 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /usr/bin/../lib64/libstdc++.so.6
#2  0x00007ffdb6de8a9b in llvm::MCTargetOptions::operator=(llvm::MCTargetOptions const&) ()
   from /usr/lib64/dri/swrast_dri.so
#3  0x00007ffdb6de8dc9 in llvm::TargetOptions::operator=(llvm::TargetOptions const&) ()
   from /usr/lib64/dri/swrast_dri.so
#4  0x00007ffdb6de8df7 in llvm::EngineBuilder::setTargetOptions(llvm::TargetOptions const&) ()
   from /usr/lib64/dri/swrast_dri.so
#5  0x00007ffdb6de76cf in lp_build_create_jit_compiler_for_module () from /usr/lib64/dri/swrast_dri.so
#6  0x00007ffdb6de6124 in gallivm_compile_module () from /usr/lib64/dri/swrast_dri.so
#7  0x00007ffdb71338a1 in llvmpipe_update_fs () from /usr/lib64/dri/swrast_dri.so
#8  0x00007ffdb712bdf0 in llvmpipe_update_derived () from /usr/lib64/dri/swrast_dri.so
#9  0x00007ffdb7117d84 in llvmpipe_draw_vbo () from /usr/lib64/dri/swrast_dri.so
#10 0x00007ffdb6ba0800 in st_draw_vbo () from /usr/lib64/dri/swrast_dri.so
#11 0x00007ffdb6b61f3c in vbo_validated_drawrangeelements () from /usr/lib64/dri/swrast_dri.so
#12 0x00007ffdb6b623a9 in vbo_exec_DrawElements () from /usr/lib64/dri/swrast_dri.so
#13 0x00007ffddb713ef1 in QSGBatchRenderer::Renderer::renderMergedBatch(QSGBatchRenderer::Batch const*) ()
   from /usr/lib64/libQt5Quick.so.5
#14 0x00007ffddb715195 in QSGBatchRenderer::Renderer::renderBatches() () from /usr/lib64/libQt5Quick.so.5
#15 0x00007ffddb71aa45 in QSGBatchRenderer::Renderer::render() () from /usr/lib64/libQt5Quick.so.5
#16 0x00007ffddb72632f in QSGRenderer::renderScene(QSGBindable const&) () from /usr/lib64/libQt5Quick.so.5
#17 0x00007ffddb7269fb in QSGRenderer::renderScene(unsigned int) () from /usr/lib64/libQt5Quick.so.5
#18 0x00007ffddb73660e in QSGRenderContext::renderNextFrame(QSGRenderer*, unsigned int) ()
   from /usr/lib64/libQt5Quick.so.5
#19 0x00007ffddb77f86e in QQuickWindowPrivate::renderSceneGraph(QSize const&) ()
   from /usr/lib64/libQt5Quick.so.5
#20 0x00007ffddb74cf55 in QSGGuiThreadRenderLoop::renderWindow(QQuickWindow*) ()
   from /usr/lib64/libQt5Quick.so.5
#21 0x00007ffddb74e1a8 in QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow*) ()
   from /usr/lib64/libQt5Quick.so.5
#22 0x00007ffdda6702c5 in QWindow::event(QEvent*) () from /usr/lib64/libQt5Gui.so.5
#23 0x00007ffddb78a1b3 in QQuickWindow::event(QEvent*) () from /usr/lib64/libQt5Quick.so.5
#24 0x00007ffddb0d696c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib64/libQt5Widgets.so.5
#25 0x00007ffddb0de111 in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQt5Widgets.so.5
---Type <return> to continue, or q <return> to quit---
#26 0x00007ffdda3260ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /usr/lib64/libQt5Core.so.5
#27 0x00007ffdda665d2d in QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) () from /usr/lib64/libQt5Gui.so.5
#28 0x00007ffdda66695d in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib64/libQt5Gui.so.5
#29 0x00007ffdda6477cb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    () from /usr/lib64/libQt5Gui.so.5
#30 0x00007ffdd3433c60 in userEventSourceDispatch(_GSource*, int (*)(void*), void*) ()
   from /usr/bin/../lib64/libQt5XcbQpa.so.5
#31 0x00007ffdd6de4e42 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#32 0x00007ffdd6de51c0 in g_main_context_iterate.isra () from /usr/lib64/libglib-2.0.so.0
#33 0x00007ffdd6de526c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#34 0x00007ffdda373d5f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib64/libQt5Core.so.5
#35 0x00007ffdda32507a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib64/libQt5Core.so.5
#36 0x00007ffdda32cb7c in QCoreApplication::exec() () from /usr/lib64/libQt5Core.so.5
#37 0x00007ffddb9d03a8 in load_qml_app () from /home/bjanssens/.julia/v0.5/LoadQML/deps/usr/lib/libloadqml.so
@tkelman
Copy link
Contributor

tkelman commented Dec 15, 2016

It's having different versions of llvm both dynamically linked and loaded into the same process. @Keno knows more, and has been trying to get distro graphics driver maintainers to go back to linking llvm statically I believe. Not sure if their reasons for changing to shared library linking are better or worse or just different than ours.

@tkelman
Copy link
Contributor

tkelman commented Dec 15, 2016

We went through this once before with having multiple llvm versions on disk at the same time, now we're getting to having multiple llvm versions in memory at the same time. I wonder if maybe llvm should version their namespace?

@Keno
Copy link
Member

Keno commented Dec 15, 2016

Yeah complain to your Linux distribution. It's their fault. The Mesa projects strongly recommends against linking their drivers dynamically for this reason. This can also be fixed with a change to C++ semantics (and I have a patch pending to Clang that adds an attribute to opt into such semantics). Nevertheless, we may be forced to consider renaming LLVM symbols ourselves because of this.

@ihnorton
Copy link
Member

ihnorton commented Dec 3, 2017

It looks like everyone is resolving this with the symbol versioning added to LLVM in:

https://reviews.llvm.org/D31524

Unfortunately, that is not in 3.9, and may only help if both LLVM libraries are versioned (I've read something to that effect in one of the threads below, and Julia nightly on Ubuntu 17.04 still encounters this issue -- where mesa is using libLLVM-4.0).

x-ref some upstream discussions:

https://bugs.freedesktop.org/show_bug.cgi?id=93103
https://bugs.kde.org/show_bug.cgi?id=383086
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=846410

(FWIW there's a nice simple reproducer here: https://github.com/Axel-Naumann/llvm-mesa-reproducer , from https://sft.its.cern.ch/jira/browse/ROOT-7744)

ihnorton added a commit to ihnorton/julia that referenced this issue Dec 3, 2017
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  JuliaLang#19606
ihnorton added a commit to ihnorton/julia that referenced this issue Dec 3, 2017
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  JuliaLang#19606

patch: https://reviews.llvm.org/D31524
commit: https://reviews.llvm.org/rL300496
ihnorton added a commit to ihnorton/julia that referenced this issue Jan 16, 2018
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  JuliaLang#19606

patch: https://reviews.llvm.org/D31524
commit: https://reviews.llvm.org/rL300496
vchuravy pushed a commit that referenced this issue Jan 16, 2018
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  #19606

patch: https://reviews.llvm.org/D31524
commit: https://reviews.llvm.org/rL300496
ararslan pushed a commit that referenced this issue May 8, 2018
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  #19606

patch: https://reviews.llvm.org/D31524
commit: https://reviews.llvm.org/rL300496

Ref #25597
(cherry picked from commit edabf42)
ararslan pushed a commit that referenced this issue May 27, 2018
Should help with crashes when loading multiple libLLVM versions in
the same process, as happens with mesa/llvmpipe when mesa is
dynamically linked against libLLVM. See

  #19606

patch: https://reviews.llvm.org/D31524
commit: https://reviews.llvm.org/rL300496

Ref #25597
(cherry picked from commit edabf42)
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

Successfully merging a pull request may close this issue.

4 participants