Opened 12 years ago

Closed 12 years ago

#4854 closed Bugs (invalid)

boost ptr_list serious problem

Reported by: davidmahorse@… Owned by: Thorsten Ottosen
Milestone: To Be Determined Component: ptr_container
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

I have defined a struct like below: there is a mutex in it. I just found this mutex cannot cross-thread,strang? But stl c++ list works well. It doesn't have such a strange problem. struct { ..... ptr_list<SeppContext> freeContextList; } when i invoke freeContextList.mutex1, I try:

freeContextList.mutex1.lock();

then a boost lock error jumped up. It is not my codes'problem. It is the problem of ptr_list of boost. strange?

Change History (7)

comment:1 by Marshall Clow, 12 years ago

Can you post a complete code example, please?

Something that we can try to compile?

in reply to:  1 comment:2 by davidmahorse@…, 12 years ago

Replying to marshall:

Can you post a complete code example, please?

Something that we can try to compile?

I cannot upload my source.It is too big even if after I make clean. I have tested today. It is still a problem. If you want talk me in detail. You can join me in MSN my msn is: david_mahorse@… I could send my full source to you by pidgin of ubuntu 10.04.

Last edited 12 years ago by René Rivera (previous) (diff)

comment:3 by viboes, 12 years ago

Please could you clarify what is the context and the error?

comment:4 by davidmahorse@…, 12 years ago

struct SeppContext { .....

mutex lockForSingleContext;mutex is a stand version of boost.

..... }

class sepp { .... list<SeppContext*> freeContextList; this stl list works fine ptr_list<SeppContext> freeContextList;this doesn't work ,it cannot crossthread such as epoll linux kernel }

I was trying to test my codes to handle exception: so I deliberately throw an exception in one function invoked by epoll threads which I defined. This exception is created by this sentence like that: ... scoped_array<char> pa(new char[0x7fffffff]); .... then I just didn't know there is a problem with ptr_list of boost. I just get strange exception of "boost lock" captured by my threads. At this time ,this point of "SeppContext" has entered in linux kernel of epoll and comes out. I traced where this exception comes from, then I find : .... pContext = freeContextList.back(); freeContextList.pop_back(); pContext->lockForSingleContext.lock();this sentence throws boost lock exception .... But I have found this point of pContext is good. The address of pContext is not changed by kernel of linux. But I can invoke other variable of this pContext. But I cannot invoke the mutex of lockForSingleContext in SeppContext. If I invoke then a boost lock exception jumps out. I have't use static_cast such things. Because I only have one process,but it is mult-threaded. And if I don't use ptr_list of boost, I find std list works fine. It doesn't throw boost lock exception. So I judge this is not the problem of my codes. It is the problem of boost ptr_list. I just found another serious problem of ip:tcp:socket. The socket handle in it cannot cross-thread. The problem is I cannot delete point of ip:tcp:socket to release socket handle. This point of ip:tcp:socket is also defined in SeppContext. It is not the problem of my codes. It is the problem of ASIO of boost.Trust me. I don't use ASIO now. I just use BSD socket raw functions. It works fine. All my environment is multi-threads and epoll things. Because I am doing basic network programming.

comment:5 by davidmahorse@…, 12 years ago

Why don't you join me in google talk to know detail of it? My gmail and account of google of talk is: davidmahorse@…

comment:6 by viboes, 12 years ago

Component: Noneptr_container
Owner: set to Thorsten Ottosen

comment:7 by Thorsten Ottosen, 12 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.