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

Invalid free/delete error in Boost.Test with minimal test case on Boost 1.85

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp, linux
领域
testing-qa

调研方向

在 Valgrind 下使用 Boost.Test 1.85 重现最小测试用例,然后检查 unit_test_parameters.ipp 和 test_instrument.cpp 中所示的静态初始化和销毁路径。确认 invalid free 发生在进程退出时,并记录或修复相关的 lifetime 问题,使测试在没有 Valgrind 错误的情况下退出。

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

描述

I encountered an invalid free/delete error when running a minimal test case using Boost.Test with Boost 1.85. Below is the code and the error message from Valgrind.

Minimal Test Case:

#define BOOST_TEST_MODULE MinimalTest
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE(minimal_test)
{
    BOOST_CHECK_EQUAL(1, 1);
}

Error Message from Valgrind:

==49727== Invalid free() / delete / delete[] / realloc()
==49727== at 0x484668F: operator delete(void*) (vg_replace_malloc.c:1131)
==49727== by 0x4CD467F: __cxa_finalize (cxa_finalize.c:82)
==49727== by 0x487CD96: ??? (in /usr/local/lib/libboost_unit_test_framework.so.1.85.0)
==49727== by 0x40010F1: _dl_call_fini (dl-call_fini.c:43)
==49727== by 0x40050AD: _dl_fini (dl-fini.c:114)
==49727== by 0x4CD4BB0: __run_exit_handlers (exit.c:108)
==49727== by 0x4CD4C7D: exit (exit.c:138)
==49727== by 0x4CBC08E: (below main) (libc_start_call_main.h:74)
==49727== Address 0x4e957c0 is 0 bytes inside a block of size 18 free'd
==49727== at 0x4846B81: operator delete(void*, unsigned long) (vg_replace_malloc.c:1181)
==49727== by 0x487715: std::__new_allocator::deallocate(char*, unsigned long) (new_allocator.h:172)
==49727== by 0x45D40E: UnknownInlinedFun (allocator.h:208)
==49727== by 0x45D40E: UnknownInlinedFun (alloc_traits.h:513)
==49727== by 0x45D40E: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_destroy(unsigned long) (basic_string.h:294)
==49727== by 0x45BA33: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_dispose() (basic_string.h:288)
==49727== by 0x415A25: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string() (basic_string.h:809)
==49727== by 0x4CD4BB0: __run_exit_handlers (exit.c:108)
==49727== by 0x4CD4C7D: exit (exit.c:138)
==49727== by 0x4CBC08E: (below main) (libc_start_call_main.h:74)
==49727== Block was alloc'd at
==49727== at 0x4842FB5: operator new(unsigned long) (vg_replace_malloc.c:487)
==49727== by 0x45BA87: std::__new_allocator::allocate(unsigned long, void const*) (new_allocator.h:151)
==49727== by 0x44539F: UnknownInlinedFun (allocator.h:196)
==49727== by 0x44539F: UnknownInlinedFun (alloc_traits.h:478)
==49727== by 0x44539F: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_S_allocate(std::allocator&, unsigned long) (basic_string.h:131)
==49727== by 0x4452D5: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned long) (basic_string.tcc:159)
==49727== by 0x444F3B: void std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (basic_string.tcc:229)
==49727== by 0x4245A7: std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string<std::allocator >(char const*, std::allocator const&) (basic_string.h:654)
==49727== by 0x4A5C7A: __static_initialization_and_destruction_0() (unit_test_parameters.ipp:97)
==49727== by 0x4AF515: _GLOBAL__sub_I__ZN5boost9unit_test6output22compiler_log_formatter9log_startERSom (test_instrument.cpp:14)
==49727== by 0x4CBC1C3: call_init (libc-start.c:145)
==49727== by 0x4CBC1C3: __libc_start_main@@GLIBC_2.34 (libc-start.c:347)
==49727== by 0x40E944: (below main) (in /home/avatli/workspace/bull/hft-api/build/tests/test_instrument)

Steps to Reproduce:

  1. Create a minimal test case as shown above.
  2. Compile and link the test case using Boost.Test.
  3. Run the test with Valgrind to observe the error.

Additional Information:

  1. Boost version: 1.85
  2. Compiler: g++ (GCC) 14.1.1 20240620 (Red Hat 14.1.1-6)
  3. Operating System: Linux fedora 6.9.5-200.fc40.x86_64
主要语言
C++
星标
217
派生
149
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

boostorg/test 的其他 Issue

查看 boostorg/test 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

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