美文网首页
pure virtual method called

pure virtual method called

作者: 叶迎宪 | 来源:发表于2019-10-27 01:07 被阅读0次

编写的一段在arm芯片跑的小程序,同样的代码在x86运行正常,在arm上面运行报错
pure virtual method called
terminate called without an active exception

用gdb查看

#0  0xb6cfd824 in raise () from /lib/libc.so.6
#1  0xb6cfebd8 in abort () from /lib/libc.so.6
#2  0xb6f3a3ac in __gnu_cxx::__verbose_terminate_handler() ()
   from /lib/libstdc++.so.6
#3  0xb6f38224 in __cxxabiv1::__terminate(void (*)()) ()
   from /lib/libstdc++.so.6
#4  0xb6f38298 in std::terminate() () from /lib/libstdc++.so.6
#5  0xb6f38f50 in __cxa_pure_virtual () from /lib/libstdc++.so.6
#6  0xb6f975ec in execute_native_thread_routine () from /lib/libstdc++.so.6
#7  0xb6e16f38 in ?? () from /lib/libpthread.so.0
#8  0xb6da0360 in ?? () from /lib/libc.so.6

虽然调用栈看不出源代码是哪里出的问题,但是execute_native_thread_routine猜到应该是启动线程的地方。源代码就一处调用了std::thread来启动线程。用搜索引擎查到
https://stackoverflow.com/questions/23583317/c-11-threads-error-pure-virtual-function-called#

这应该是glibc的一个bug,用最简单的std::thread的例子程序,都会出现运行报错。最终解决,在编译的时候加上
-march=armv7-a

相关文章

网友评论

      本文标题:pure virtual method called

      本文链接:https://www.haomeiwen.com/subject/ghcpvctx.html