boost :: exception_detail :: clone_impl< boost :: exception_detail :: error_info_injector< boost :: thread_resource_error> > [英] boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >
问题描述
我需要一些帮助这个异常,我实现一个NPAPI插件,以便能够使用浏览器扩展中的本地套接字,这样做,我使用Firebreath框架。
对于套接字和连接我使用Boost asio与异步调用和线程池的5个工作线程。
我的插件的扩展工作流程如下:
- 打开套接字1(这将启动一个async_receive和截止日期
async_wait) - 在套接字1中写入
-
取得回应1
-
写入套接字2
-
关闭套接字1
(socket.cancel(),deadline.cancel(),socket.shutdown(),socket
release)。 关闭套接字2
由于一切都是交叉语言,异步真的很难调试,但所有打开,写入或关闭都是从javascript和从套接字1读取,调用open 2,write 2,write 1,并按顺序关闭1.
也许evrything我说的是不相关的调用堆栈异常被抛出不显示任何我的函数,只显示它在调用 _heap_alloc_dbg_impl
malloc
p>
因为它通常在第二或第三个完整周期失败,似乎发生在步骤5和7之间。
但是,我认为它必须是asio相关,因为做一切与一个工作线程只是崩溃与第一个周期的异常。
我可以发布
$ b 更新1:
更新2: strong>
有10个线程启动:
workPtr .reset(new boost :: asio :: io_service :: work(io_service));
for(int i = 0; i <10; ++ i){
m_threadGroup.create_thread(boost :: bind(& boost :: asio :: io_service :: run ,& io_service));
}
第11个_threadstartex我不知道是谁启动它
在另一个线程(不是VS声称导致崩溃的线程)中有一个 join_all()
被破坏,但我认为它不应该,所以也许这次崩溃是由于另一个异常和Firebreath过程,当它崩溃时关闭一切。
我发现错误通过继续检查其他线程。我发现我的Firebreath调用的主类是在被销毁的过程中。检查一点更多我发现这是完全是我的错我有一个类存储套接字信息需要使用一个函数在主类(我不喜欢它,但它是我发现使用它的唯一方式)所以我添加了一个 shared_ptr
到主类。因此,如果它在破坏那些 SocketInfo
对象后,因为没有其他对象,ptr引用计数达到0,并且主体类被销毁。
有趣的是,套接字通常在使用后正常关闭,所以我没有看到没有理由为什么没有触发时没有打开套接字,只发生在2个套接字在一行中打开和关闭。 / p>
无论如何我也有一个 shared_from_this
错误的截止处理程序,但似乎无关。
现在看起来它正在按照任意数量的线程工作。
I need some help with this exception, I am implementing a NPAPI plugin to be able to use local sockets from browser extensions, to do that I am using Firebreath framework.
For socket and connectivity I am using Boost asio with async calls and a thread pool of 5 worker threads. Also I have a deadline per thread to implement a transmission timeout.
My extension workflow with the plugin is as this:
- Open socket 1(this starts a async_receive and the deadline async_wait)
- Write in the socket 1
Get response 1
Open another socket 2
Write in the socket 2
Write socket 1
Close socket 1 (socket.cancel(), deadline.cancel(), socket.shutdown(), socket release).
Get response 2
- Write socket 2
- Close socket 2
As everything is cross language and async is really hard to debug but all open, write or close are called from javascript and the read from socket 1 that calls open 2, write 2, write 1 and close 1 in that order.
Maybe evrything I am telling is unrelated as the call stack when the exception is thrown does not show any of my functions and only show that it is inside a malloc
that calls _heap_alloc_dbg_impl
As it is it usually fails in the 2nd or 3rd full cycle and it seems that happens between steps 5 and 7.
But, I think that it must be asio related as doing everything with a single worker thread just crashes with the exception on the first cycle.
I am open to publish more information code if you need it.
Update 1:
Update 2:
There are 10 threads are launched with:
workPtr.reset( new boost::asio::io_service::work(io_service));
for ( int i = 0; i < 10; ++i) {
m_threadGroup.create_thread( boost::bind(&boost::asio::io_service::run, &io_service) );
}
The 11th _threadstartex I don't know who launched it
On another thread (not the one that VS claims as causing the crash) there is a join_all()
in process because my class is being destroyed but I think it shouldn't, so maybe this crash is due to another exception and the Firebreath process to close everything when it crashes.
I found the errors by continuing to inspect the other threads. I found that my principal class that Firebreath was invoking was in the process of being destroyed. Inspecting a little more I found that it was totally my fault I have a class for storing the sockets information that needed to use a function in the principal class (I didn't like it but it was the only way I found to use it) so I added a shared_ptr
to the principal class. So if it after destroying on of those SocketInfo
objects as there were no others the ptr ref count reached 0 and the principal class was being destroyed.
What is fun is that sockets usually close normally after being used so I see no reason why this was not triggered when there were not sockets opened and only happened when 2 sockets where opened and closed in a row.
Anyway I also had a shared_from_this
error with the deadline handler but that seemed unrelated.
And now it seems it is working as expected with any number of threads.
这篇关于boost :: exception_detail :: clone_impl< boost :: exception_detail :: error_info_injector< boost :: thread_resource_error> >的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!