Coder Social home page Coder Social logo

Comments (3)

okeuday avatar okeuday commented on June 3, 2024

It is possible to avoid this segfault by using clang instead of gcc for the compilation. Using either libunwind (LLVM unwinder) or libgcc (GCC unwinder) as the clang -unwindlib value for link-time results in a compilation that doesn't have the http_req_c binary segfault when performing rapid C++ throw execution. The compilations used are shown below from usage on Ubuntu 20.04 LTS (with its packages):

-unwindlib=libunwind usage below:

export CXX='clang++-10'
export CC='clang-10'
export CXXFLAGS='-I/usr/include/c++/9 -I/usr/include/x86_64-linux-gnu/c++/9'
export LDFLAGS='-rtlib=compiler-rt -unwindlib=libunwind -L/usr/lib/gcc/x86_64-linux-gnu/9'
./configure
make
# ... install and other commands as done previously

-unwindlib=libgcc usage below:

export CXX='clang++-10'
export CC='clang-10'
export CXXFLAGS='-I/usr/include/c++/9 -I/usr/include/x86_64-linux-gnu/c++/9'
export LDFLAGS='-unwindlib=libgcc -L/usr/lib/gcc/x86_64-linux-gnu/9'
./configure
make
# ... install and other commands as done previously

The same nongnu-libunwind library (version 1.2.1) is linked in both compilations for C++ backtrace support, though the execution is able to avoid using nongnu-libunwind for exception handling, which avoids the segfault under load.

The segfault also didn't occur when using a build with gcc on Ubuntu 22.04 LTS in a VirtualBox VM which is using nongnu-libunwind library (version 1.3.2).

from cloudi.

ojura avatar ojura commented on June 3, 2024

Hi, I am the bug submitter.

Note that compilers (e.g. gcc) provide their own internal unwinder. It’s like malloc - you can provide and link your own, and then it replaces the default one. Same with libunwind, which overrides __cxa_throw; gcc provides an internal one if you do not link libunwind.

in my case, libunwind was linked in transitively because glog specified it as a dependency. However, it is entirely optional and glog can use gcc’s internal unwinder too to read backtraces. I had to manually purge (in CMake) libunwind from the link list of my application and dynamic library targets. Then then bug is avoided because gcc’s internal unwinder is used.

@okeuday to summarize: your title is a bit wrong, gcc’s libstdc++ per se does not depend on libunwind, some other 3rd party is pulling it in (it was glog for me) and you should kick it out from being linked in. libunwind is not essential and this version just causes problems.

And my condolences for running into this :) it is truly awful

from cloudi.

okeuday avatar okeuday commented on June 3, 2024

@ojura Removing libunwind 1.2.1 from the compilation (with gcc/g++) does avoid the segfault. I had been hoping to keep it in the compilation because it had improved the backtrace information in the past but it looks like it is better to keep libunwind out of the compilation to keep the situation simpler and reduce the number of potential problems (it helps to ensure future reliability of CloudI source code).

Just to be clear, libstdc++ uses the libgcc unwinder which segfaults only when (nongnu) libunwind 1.2.1 is part of the compilation (and is linked to the executable) gcc/g++ creates when using optimization levels -O1 or higher. I updated the title to show that libunwind was the problem. Thank you for providing the additional information.

from cloudi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.