문제

비글 버전 블랙에서 사용하기 위해 이벤트 기반 프로그래밍 라이브러리를 작성하고 이상한 오류가 발생했습니다.

똑같은 플래그로 똑같은 코드를 컴파일 할 때 ARM 기반 프로세서에 다음 오류가 발생하지만 x86 컴퓨터에 대해 컴파일 된 코드를 실행할 때는 아닙니다.

$ ./missionControl
pure virtual method called
pure virtual method called
pure virtual method called
terminate called recursively
terminate called recursively
Aborted
.

랩톱에서 컴파일하고 실행하면 프로그램이 올바르게 를 실행합니다.

이것은 내가 컴파일하는 데 사용하는 명령입니다 (iSH, 나는 makefile을 사용하고 있지만, 두 가지 방법 모두 동일한 동작을 정확하게 보여줍니다) :

g++ -std=gnu++11 -pthread -O3 -D_GLIBCXX_USE_NANOSLEEP -o missionControl `find . -name *.cpp`
.

Ubuntu의 arm-linux-gnueabi-g++ 또는 실제 비글 버전에서 ARM 호환 PeranaCodicetag 코드를 교차 컴파일하는지 여부는 중요하지 않습니다.

내 질문은이 오류를 일으킬 수있는 것이 무엇인지, 소스를 찾으려고 할 수있는 일은 무엇입니까? 왜 하나의 프로세서 아키텍처에서는 이런 일이 일어나지 만 동일한 버전의 G ++?

감사합니다!

여기 다음은 ARM 프로세서의 GDB의 백 트레이스입니다.

#0  0xb6d4adf8 in raise () from /lib/libc.so.6
#1  0xb6d4e870 in abort () from /lib/libc.so.6
#2  0xb6f50ab4 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#3  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
#4  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
.

도움이 되었습니까?

해결책

비글 버전에서 실행되는 LIBSTDC ++의 ARM 버전의 버그로 인해 문제가 발생했습니다.가상 함수가 전혀없는 작은 장난감 프로그램은 STD :: 스레드가 생성 될 때 동일한 오류 ( "순수 가상 함수"라고 함)를 생성합니다.

비글 버전 자체에서 GCC / libstdc ++ 4.8의 사용자 정의 버전을 컴파일하려고 시도 할 것입니다.

다른 팁

The pure virtual method called error occurs when you attempt to use dynamic dispatch to call a function that is pure virtual in a base before the derived type that implements it has been constructed or after it has already destructed.

The most common cause for this is if the base class attempts to call a virtual function that is pure at this level through the constructor or destructor. Other than that, as it has been pointed out in some comments, if you attempt to access a dead object, you might also run into this same issue.

Just attach a debugger to the program and see what virtual function is called and from where.

See: https://groups.google.com/forum/#!topic/automatak-dnp3/Jisp_zGhd5I

And: Why does this simple c++11 threading-example fail, when compiled with clang 3.2?

Now, I have no idea why this works, but it does for me at least. Add the following four preprocessor definitions to the compiler command line:

__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8

I haven't experimented to see if they are all required, or whether or not you can get away with only some. But this solved the problem for me. Thanks to those who wrote the above answers, and thanks to my colleague for out-googling me :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top