Invalid free/delete error in Boost.Test with minimal test case on Boost 1.85
还没有人认领这个 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:
- Create a minimal test case as shown above.
- Compile and link the test case using Boost.Test.
- Run the test with Valgrind to observe the error.
Additional Information:
- Boost version: 1.85
- Compiler: g++ (GCC) 14.1.1 20240620 (Red Hat 14.1.1-6)
- Operating System: Linux fedora 6.9.5-200.fc40.x86_64
- 主要语言
- C++
- 星标
- 217
- 派生
- 149
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
boostorg/test 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 52/100
-
Conversion Warning with GCC15 when using operator<< within custom failure message and -WConversion未关闭
难度 4/5 3-5 天 新手友好度 42/100
相似的 Issue
-
Status: Awaiting triage
难度 2/5 1-3 小时 新手友好度 75/100
espressif/arduino-esp32#12984 ·
维护者通常 1 天内回复
-
torch_ops/logprob.cu does not compile with the serving container's nvcc (13.3.73); check_torch_ops.py cannot run as shipped可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1 小时以内 新手友好度 72/100
ashhart/TensorFold#535 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复