gabor_papp
Posts: 3
Joined: Fri Jan 08, 2016 3:03 pm

std::thread crash with clang

Fri Jan 08, 2016 3:23 pm

Hi,

I'm trying to build the following simple threading test on a PI2 with Raspbian (Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT armv7l GNU/Linux).

Code: Select all

#include <iostream>
#include <thread>

int main( int argc, char **argv )
{
    std::thread thr( []() { std::cout << "Hello thread" << std::endl; } );
    thr.join();

    return 0;
}
Building with g++ works fine, but with

Code: Select all

clang++ -ggdb -std=c++11 -pthread -g0 -o test test.cpp
the built executable crashes with the following message:

pure virtual method called
terminate called without an active exception
Aborted

I found a couple of similar issues by google search with the following command line parameter suggestions:
  • * -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4,8}
    * -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
    * -mcpu=cortex-a8
    * -march=armv6
But none of these seem to work.

Any suggestions would be greatly appreciated.

-Gabor

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: std::thread crash with clang

Sat Jan 09, 2016 8:02 am

This appears to be a bug in clang++. Have a look at bug: 23165 on llvm.org. From my reading of the bug reports, there was a more general bug some time back that resulted in similar output, that could be fixed using the methods you have outlined. I think this is a different issue. The person reporting the bug appears to be using clang++ 3.7.0. I think there was a recent release of 3.7.1 (llvm.org is now timing out for me as I write this). I think your options are either switch to g++ or try and compile and install a newer version of clang++.

I don't think you are going to find a work around. Although, it would be great if someone came up with a work around.

gabor_papp
Posts: 3
Joined: Fri Jan 08, 2016 3:03 pm

Re: std::thread crash with clang

Sat Jan 09, 2016 2:36 pm

Thank you.

gabor_papp
Posts: 3
Joined: Fri Jan 08, 2016 3:03 pm

Re: std::thread crash with clang

Sun Jan 10, 2016 8:51 pm

I built the test file with clang 3.7.1 downloaded from llvm.org (http://llvm.org/releases/3.7.1/clang+ll ... ihf.tar.xz) and the issue persists.

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: std::thread crash with clang

Sun Jan 10, 2016 9:23 pm

gabor_papp wrote:I built the test file with clang 3.7.1 downloaded from llvm.org (http://llvm.org/releases/3.7.1/clang+ll ... ihf.tar.xz) and the issue persists.
That is frustrating. Perhaps file a bug report on LLVM (How to submit an LLVM bug report).

nishu2901
Posts: 4
Joined: Wed Apr 10, 2019 1:43 pm

Re: std::thread crash with clang

Thu Apr 11, 2019 3:43 am

Did you guys resolve this issue ? And if yes, then can you suggest how you did that ?


Return to “Raspbian”