使用共享库时出现分段错误

发布于 2024-10-31 12:00:05 字数 1360 浏览 5 评论 0原文

我正在 Linux 上构建一个共享库。 收到分段错误:“分段错误(治愈转储)”

库“.so”已成功创建,但是当我尝试将其链接到测试应用程序(带有空主程序)并运行可执行文件时,我在尝试调试时 使用 gdb 并检查回溯,我得到了以下输出:

Program received signal SIGSEGV, Segmentation fault.
0x0073d5df in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12.1-4.i686 libgcc-4.4.5-2.fc13.i686 libstdc++-4.4.5-2.fc13.i686 zlib-1.2.3-23.fc12.i686

(gdb) backtrace

#0  0x0073d5df in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6
#1  0x0012d70c in ?? () from /opt/cuda/lib/libcudart.so.3
#2  0x0012df0c in ?? () from /opt/cuda/lib/libcudart.so.3
#3  0x0012c88a in ?? () from /opt/cuda/lib/libcudart.so.3
#4  0x00121435 in __cudaRegisterFatBinary () from /opt/cuda/lib/libcudart.so.3
#5  0x005d7bfd in __sti____cudaRegisterAll_55_tmpxft_00000fe6_00000000_26_MonteCarloPaeo_SM10_cpp1_ii_3a8af011()
    () from libsharedCUFP.so
#6  0x005db40d in __do_global_ctors_aux () from libsharedCUFP.so
#7  0x005a8748 in _init () from libsharedCUFP.so
#8  0x008abd00 in _dl_init_internal () from /lib/ld-linux.so.2
#9  0x0089d88f in _dl_start_user () from /lib/ld-linux.so.2

Im notimit with gdb debugging, and it's the the first time Im attempts to build a共享库在Linux上,但在我看来,它与库动态链接有关。

如果有人对此错误有任何想法并可以帮助我,我将不胜感激。

Im building a shared library on linux. the library ".so" was sucessfully created, but when I tried to link it to a test application (with an empty main) and run the executable I got a segmentation error : "Segmentation error (cure dumped)"

when I tried to debug it with gdb and check the backtrace I got this output:

Program received signal SIGSEGV, Segmentation fault.
0x0073d5df in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12.1-4.i686 libgcc-4.4.5-2.fc13.i686 libstdc++-4.4.5-2.fc13.i686 zlib-1.2.3-23.fc12.i686

(gdb) backtrace

#0  0x0073d5df in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6
#1  0x0012d70c in ?? () from /opt/cuda/lib/libcudart.so.3
#2  0x0012df0c in ?? () from /opt/cuda/lib/libcudart.so.3
#3  0x0012c88a in ?? () from /opt/cuda/lib/libcudart.so.3
#4  0x00121435 in __cudaRegisterFatBinary () from /opt/cuda/lib/libcudart.so.3
#5  0x005d7bfd in __sti____cudaRegisterAll_55_tmpxft_00000fe6_00000000_26_MonteCarloPaeo_SM10_cpp1_ii_3a8af011()
    () from libsharedCUFP.so
#6  0x005db40d in __do_global_ctors_aux () from libsharedCUFP.so
#7  0x005a8748 in _init () from libsharedCUFP.so
#8  0x008abd00 in _dl_init_internal () from /lib/ld-linux.so.2
#9  0x0089d88f in _dl_start_user () from /lib/ld-linux.so.2

Im not familiar with gdb debugging, and it's the first time Im trying to build a shared library on Linux, but it seems to me that it has something to do with the library dynamic linking.

If anyone had any idea about this error and could help me, I would be grateful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖上的星空 2024-11-07 12:00:05

它与动态链接或共享库没有任何关系 - libsharedCUFP.so 中的构造函数之一(我假设这是您的共享库)很可能将非法地址传递给 libcudart.so 中的函数,该函数崩溃了。

您只需要调试您的代码即可。

It doesn't have anything to do with dynamic linking or shared libraries - one of the constructors in libsharedCUFP.so (I assume this is your shared library) is most probably passing an illegal address to a function in libcudart.so which crashes.

You simply need to debug your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文