Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

"pure virtual method called" with `boost::current_exception()` on Ubuntu 25.04

未关闭
#60 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
43/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
cpp
领域
backend

调研方向

从最小化的 crash.cpp 程序开始,在 Ubuntu 25.04 上使用报告中的 g++ 命令重现该问题,并比较 -O0/-Og 与 -O1/-O2 以及 clang 20。检查 boost/exception/detail/exception_ptr.hpp 中 wrap_exception_ptr 和 current_exception_impl 附近的代码,以提供的 backtrace 作为入口点。完成的标准是确定故障出在 Boost 还是 GCC,并记录或修正可重现的行为。

由索引模型根据 Issue 内容生成。

描述

I'm getting an odd crash when calling boost::current_exception() on Ubuntu 25.04 (x86_64, Boost 1.83.0). The same exact code worked fine on previous versions, notably it was working on Ubuntu 24.10 that should have the same version of gcc (14.2.0).

I was able to create a minimized program (below) that reproduces the issue reliably when built with -O0 or -Og

#include <stdexcept>
#include <boost/exception_ptr.hpp>

int main()
{
  try {
    throw std::out_of_range("foo");
  }
  catch (const std::logic_error&) {
    boost::current_exception();
  }
}

Build/run with g++ -std=c++17 -O0 -g3 crash.cpp && ./a.out

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
pure virtual method called
terminate called after throwing an instance of 'std::out_of_range'
  what():  foo

Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44
warning: 44     ./nptl/pthread_kill.c: No such file or directory
(gdb) bt full
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44
        tid = <optimized out>
        ret = 0
        pd = <optimized out>
        old_mask = {__val = {0}}
        ret = <optimized out>
        pd = <optimized out>
        old_mask = <optimized out>
        ret = <optimized out>
        tid = <optimized out>
        ret = <optimized out>
        resultvar = <optimized out>
        resultvar = <optimized out>
        __arg3 = <optimized out>
        __arg2 = <optimized out>
        __arg1 = <optimized out>
        _a3 = <optimized out>
        _a2 = <optimized out>
        _a1 = <optimized out>
        __futex = <optimized out>
        resultvar = <optimized out>
        __arg3 = <optimized out>
        __arg2 = <optimized out>
        __arg1 = <optimized out>
        _a3 = <optimized out>
        _a2 = <optimized out>
        _a1 = <optimized out>
        __futex = <optimized out>
        __private = <optimized out>
        __oldval = <optimized out>
#1  __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:89
No locals.
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:100
No locals.
#3  0x00007ffff78456de in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
        ret = <optimized out>
#4  0x00007ffff78288cd in __GI_abort () at ./stdlib/abort.c:73
        act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 0, 0, 0, 0, 140737347921251, 140737347911632, 140737488344912, 140737346375855, 1, 140737347921120, 10, 
              93824992359488, 93824992277640, 140737354125312, 140737488344960}}, sa_flags = -141976989, sa_restorer = 0x555555573428}
#5  0x00007ffff7cab05f in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#6  0x00007ffff7cc10aa in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#7  0x00007ffff7caaa9e in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#8  0x00007ffff7cc1f83 in __cxa_pure_virtual () from /lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#9  0x0000555555557ed8 in boost::exception_detail::wrap_exception_ptr (e=...) at /usr/include/boost/exception/detail/exception_ptr.hpp:68
        base = @0x7fffffffd840: {_vptr.clone_base = 0x55555555fa68 <vtable for boost::exception_detail::clone_base+16>}
#10 0x0000555555557f92 in boost::exception_ptr::exception_ptr (this=0x7fffffffd920, e=...) at /usr/include/boost/exception/detail/exception_ptr.hpp:89
No locals.
#11 0x00005555555585e7 in boost::exception_detail::current_exception_impl () at /usr/include/boost/exception/detail/exception_ptr.hpp:491
        e = 0x0
        __PRETTY_FUNCTION__ = "boost::exception_ptr boost::exception_detail::current_exception_impl()"
#12 0x0000555555558745 in boost::current_exception () at /usr/include/boost/exception/detail/exception_ptr.hpp:514
        ret = {ptr_ = {px = 0x0, pn = {pi_ = 0x0}}}
        __PRETTY_FUNCTION__ = "boost::exception_ptr boost::current_exception()"
#13 0x00005555555574d0 in main () at crash.cpp:10
No locals.
(gdb) 

I could not reproduce with clang 20 on the same platform. Raising the optimization level to -O1 or -O2 also makes the crash disappear (so, it could be a gcc miscompilation).

主要语言
C++
星标
17
派生
50
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/exception 的其他 Issue

查看 boostorg/exception 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。