“损坏的双链表”关于 boost::function free()

发布于 2024-08-06 07:47:07 字数 1587 浏览 11 评论 0原文

我将尝试在不提供太多源代码的情况下提出这个问题,因为所有相关的位加起来就是一堆。涉及的关键(我认为?)对象是

using namespace o2scl;

typedef MSMTModel<TASensor,PosModel,target2d,ovector,ovector_const_subvector> TA_MSMTModel;
typedef MPC_funct_mfptr<MSMT_InitialState,TA_MSMTModel,MSMTFormation> MPC_TAFormation_mfptr;
typedef boost::function<int (size_t, const ovector_base&, double&, TA_MSMTModel&)> TA_mfunct;

TA_mfunct mf1 = boost::bind(&MPC_TAFormation_mfptr::mfn, f1, _1, _2, _3, _4);

boost::function mf1 用作最小化例程的回调函数(o2scl::ool_mmin_spg),但我不认为我遇到的问题是特定于此的。该代码通过调用 ool_mmin_spg.mmin() 函数运行,该函数使用 mf1 作为回调,并且运行似乎没有错误。然后我收到这条可爱的消息

* glibc detectors * ./test: Corrupted double-linked list: 0x0000000001e9fb20 ***

后面跟着一个回溯和内存映射。回溯的相关行似乎是


#7 0x000000000041d32a in boost::detail::function::functor_manager, o2scl::ovector_const_subvector_tlate >, MSMTFormation>, unsigned long, o2scl::ovector_base_tlate const&, double&, dmect:: MSMTModel、o2scl::ovector_const_subvector_tlate>>、boost::_bi::list5、o2scl::ovector_const_subvector_tlate>>、MSMTFormation>> >、boost::arg<1>、boost::arg<2>、boost::arg<3>、boost::arg<4> > > >::manage (in_buffer=, out_buffer=warning: (内部错误:pc 0x41d270 在 psymtab 中读取,但不在 symtab 中读取。)


我推断从 boost::function 释放内存时存在问题,但除了我迷路了。是否有任何关于尝试调试 glibc“损坏的双链表”错误的指示?我在谷歌上找到了一些参考资料,但似乎都解决了非常具体的问题,如果有更详细的代码,请告诉我。需要剪辑,感谢您的时间!

I am going to try to ask this question without supplying too much source code because all the relevant bits add up to a bunch. The key (I think?) objects involved are

using namespace o2scl;

typedef MSMTModel<TASensor,PosModel,target2d,ovector,ovector_const_subvector> TA_MSMTModel;
typedef MPC_funct_mfptr<MSMT_InitialState,TA_MSMTModel,MSMTFormation> MPC_TAFormation_mfptr;
typedef boost::function<int (size_t, const ovector_base&, double&, TA_MSMTModel&)> TA_mfunct;

TA_mfunct mf1 = boost::bind(&MPC_TAFormation_mfptr::mfn, f1, _1, _2, _3, _4);

the boost::function mf1 is used as a callback function for a minimisation routine (o2scl::ool_mmin_spg) but I don't think the problem I am having is specific to that. The code runs with the calls to the ool_mmin_spg.mmin() function which makes use of mf1 as a callback and seems to run without errors. Then I get this lovely message

* glibc detected * ./test: corrupted double-linked list: 0x0000000001e9fb20 ***

followed by a backtrace and memory map. The relevant line of the backtrace seems to be


#7 0x000000000041d32a in boost::detail::function::functor_manager, o2scl::ovector_const_subvector_tlate >, MSMTFormation>, unsigned long, o2scl::ovector_base_tlate const&, double&, dmect::MSMTModel, o2scl::ovector_const_subvector_tlate >&>, boost::_bi::list5, o2scl::ovector_const_subvector_tlate >, MSMTFormation> >, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4> > > >::manage (in_buffer=, out_buffer=warning: (Internal error: pc 0x41d270 in read in psymtab, but not in symtab.)


I deduce that there is a problem freeing up memory from the boost::function, but other than that I am lost. Are there any pointers on trying to debug glibc "corrupted double-linked list" errors? I've found a few references on google but all have seemed to address very specific problems. Please let me know if more detailed code snips are required and thanks for your time!

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

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

发布评论

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

评论(2

凉墨 2024-08-13 07:47:07

通过 valgrind 运行程序。当内存损坏时,这将为您提供堆栈跟踪(以及与该内存块的历史记录相对应的堆栈跟踪,例如它在哪里创建,或者如果它被删除,它在哪里被销毁)。

Run the program through valgrind. That'll give you a stack trace when the memory gets corrupted (as well as a stack trace corresponding to the history of that piece of memory eg. where it was created or, if it was deleted, where it was destroyed).

脸赞 2024-08-13 07:47:07

我是 O2scl 的作者,直到现在才看到这篇文章。我检查了 spg 最小化器只是为了确定一下,我没有看到任何明显的错误,但我承认我从未尝试过以这种方式一起使用 boost::function 和 o2scl 。我会继续检查一下,但如果你弄清楚了,请告诉我。

I'm the O2scl writer and didn't see this post until now. I looked over the spg minimizer a bit just to make sure, and I didn't see anything clearly wrong, but I admit I've never tried using boost::function and o2scl together in this way. I'll continue to look things over a bit, but let me know if you figure things out.

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