New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw exception "Operation not permitted" #175

Closed
jxfwinter opened this Issue Jun 6, 2018 · 13 comments

Comments

Projects
None yet
2 participants
@jxfwinter

jxfwinter commented Jun 6, 2018

I test boost 1.67 fiber library,after run 2 hours, the process corrupted by throw exception
the error is
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted

I use g++ 7.2.1 centos 7 x86_64

this is core file:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ws_call_server...done.
[New LWP 20691]
[New LWP 20689]
[New LWP 20687]
[New LWP 20694]
[New LWP 20690]
[New LWP 20688]
[New LWP 20692]
[New LWP 20695]
[New LWP 20693]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./ws_call_server'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f81f5904277 in raise () from /lib64/libc.so.6
[Current thread is 1 (Thread 0x7f81f2a94700 (LWP 20691))]
Missing separate debuginfos, use: debuginfo-install glibc-2.17-222.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-19.el7.x86_64 libcom_err-1.42.9-11.el7.x86_64 libgcc-4.8.5-28.el7.x86_64 libselinux-2.5-12.el7.x86_64 libstdc++-4.8.5-28.el7.x86_64 openssl-libs-1.0.2k-12.el7.x86_64 pcre-8.32-17.el7.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) bt
#0  0x00007f81f5904277 in raise () from /lib64/libc.so.6
#1  0x00007f81f5905968 in abort () from /lib64/libc.so.6
#2  0x00007f81f6213ac5 in __gnu_cxx::__verbose_terminate_handler() () from /lib64/libstdc++.so.6
#3  0x00007f81f6211a36 in ?? () from /lib64/libstdc++.so.6
#4  0x00007f81f6211a63 in std::terminate() () from /lib64/libstdc++.so.6
#5  0x00007f81f6211c83 in __cxa_throw () from /lib64/libstdc++.so.6
#6  0x0000000000599b7e in std::__throw_system_error(int) ()
#7  0x00000000004db3b8 in std::unique_lock<boost::fibers::detail::spinlock_ttas>::unlock (this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/std_mutex.h:320
#8  0x00000000005258bf in boost::fibers::unbuffered_channel<WSCALL::Websocket_SendOp>::pop (value=..., this=0x7f81e1b8b360)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/unbuffered_channel.hpp:387
#9  WsCallServer::<lambda()>::operator() (__closure=<synthetic pointer>) at /root/git_abc/server_kit/src/web_tool/ws_call_server.cpp:209
#10 boost::context::detail::invoke<WsCallServer::session(SocketPtr)::<lambda()> > (fn=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/invoke.hpp:41
#11 boost::context::detail::apply_impl<WsCallServer::session(SocketPtr)::<lambda()>, std::tuple<> > (tpl=..., fn=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/apply.hpp:46
#12 boost::context::detail::apply<WsCallServer::session(SocketPtr)::<lambda()>, std::tuple<> > (tpl=..., fn=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/apply.hpp:59
#13 boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&) (this=<optimized out>, c=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:431
#14 0x000000000051dc2b in std::__invoke_impl<boost::context::fiber, boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__t=<optimized out>, __f=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:73
#15 std::__invoke<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__fn=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:96
#16 std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::__call<boost::context::fiber, boost::context::fiber&&, 0, 1> (__args=..., this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:469
#17 std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::operator()<boost::context::fiber> (this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:551
#18 boost::context::detail::invoke<std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>&, boost::context::fiber> (fn=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/invoke.hpp:41
#19 boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> >::run (fctx=<optimized out>,
    this=<optimized out>, this=<optimized out>, this=<optimized out>) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:139
#20 boost::context::detail::fiber_entry<boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> > >(boost::context::detail::transfer_t) (t=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:80
#21 0x00000000004dccdf in make_fcontext ()
#22 0x0000000000000000 in ?? ()

@jxfwinter jxfwinter closed this Jun 6, 2018

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 6, 2018

Member function pop()
channel_op_status pop( value_type & va);

Effects:
Dequeues a value from the channel. If the channel is empty, the fiber gets suspended until at least one new item is push()ed (return value success and va contains dequeued value) or the channel gets close()d (return value closed).

Throws:
Exceptions thrown by copy- or move-operations.

value_pop
Error conditions:
std::errc::operation_not_permitted

I used is pop(), but throw operation_not_permitted

@jxfwinter jxfwinter reopened this Jun 6, 2018

@olk

This comment has been minimized.

Member

olk commented Jun 6, 2018

The abort is caused by spinlock::unlock() noexcept

#7 std::unique_lock<boost::fibers::detail::spinlock_ttas>::unlock (this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/std_mutex.h:320
#8 boost::fibers::unbuffered_channel<WSCALL::Websocket_SendOp>::pop (value=..., this=0x7f81e1b8b360)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/unbuffered_channel.hpp:387

not sure how you code triggers std::atomic::store() to fail.

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 6, 2018

I used unbuffered_channel::close in other fiber, is here ?

unbuffered_channel.hpp:114
closed_.store( true, std::memory_order_release);

@olk

This comment has been minimized.

Member

olk commented Jun 6, 2018

I don't know what you want to tell me ....
As your backtrace shows, the app was aborted because an excpetion was thrown inside spinlock::unlock() used by unbuffered_channel::pop() at line unbuffered_channel.hpp:387.
spinlock::unlock() is qualified by noexcept -> std::terminate() gets called.

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 6, 2018

unbuffered_channel.hpp:382

channel_op_status pop( value_type & value) {
//382
 detail::spinlock_lock lk{ splk_producers_ };
  // notify one waiting producer
 while ( ! waiting_producers_.empty() ) {
                        context * producer_ctx = & waiting_producers_.front();
                        waiting_producers_.pop_front();
                        lk.unlock();// would more than once unlock?

olk added a commit that referenced this issue Jun 6, 2018

@olk

This comment has been minimized.

Member

olk commented Jun 6, 2018

I've added a patch - could you verify if it is working, please

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 7, 2018

used patch, I can not reappear operation_not_permitted exception, but sometimes, Program terminated with signal SIGSEGV, Segmentation fault。

core file:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./ws_call_server'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000004d7d9c in boost::fibers::context::suspend_with_cc() ()
[Current thread is 1 (Thread 0x7f2036ffd700 (LWP 4418))]
Missing separate debuginfos, use: debuginfo-install glibc-2.17-222.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-19.el7.x86_64 libcom_err-1.42.9-11.el7.x86_64 libgcc-4.8.5-28.el7.x86_64 libselinux-2.5-12.el7.x86_64 libstdc++-4.8.5-28.el7.x86_64 openssl-libs-1.0.2k-12.el7.x86_64 pcre-8.32-17.el7.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) bt
#0  0x00000000004d7d9c in boost::fibers::context::suspend_with_cc() ()
#1  0x00000000004dbf64 in boost::fibers::scheduler::terminate(std::unique_lock<boost::fibers::detail::spinlock_ttas>&, boost::fibers::context*) ()
#2  0x00000000004d8bfe in boost::fibers::context::terminate() ()
#3  0x0000000000522012 in boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&) (this=0x7f201842f900, c=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:437
#4  0x000000000051de5b in std::__invoke_impl<boost::context::fiber, boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__t=<optimized out>, __f=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:73
#5  std::__invoke<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__fn=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:96
#6  std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::__call<boost::context::fiber, boost::context::fiber&&, 0, 1> (__args=..., this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:469
#7  std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::operator()<boost::context::fiber> (this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:551
#8  boost::context::detail::invoke<std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>&, boost::context::fiber> (fn=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/invoke.hpp:41
#9  boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> >::run (fctx=<optimized out>,
    this=<optimized out>, this=<optimized out>, this=<optimized out>) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:139
#10 boost::context::detail::fiber_entry<boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> > >(boost::context::detail::transfer_t) (t=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:80
#11 0x00000000004dcd4f in make_fcontext ()
#12 0x0000000000000000 in ?? ()
(gdb) info f
Stack level 0, frame at 0x7f201842f600:
 rip = 0x4d7d9c in boost::fibers::context::suspend_with_cc(); saved rip = 0x4dbf64
 called by frame at 0x7f201842f620
 Arglist at 0x7f201842f5d0, args:
 Locals at 0x7f201842f5d0, Previous frame's sp is 0x7f201842f600
 Saved registers:
  rbx at 0x7f201842f5e8, rbp at 0x7f201842f5f0, rip at 0x7f201842f5f8
(gdb) up
#1  0x00000000004dbf64 in boost::fibers::scheduler::terminate(std::unique_lock<boost::fibers::detail::spinlock_ttas>&, boost::fibers::context*) ()
(gdb) info f
Stack level 1, frame at 0x7f201842f620:
 rip = 0x4dbf64 in boost::fibers::scheduler::terminate(std::unique_lock<boost::fibers::detail::spinlock_ttas>&, boost::fibers::context*); saved rip = 0x4d8bfe
 called by frame at 0x7f201842f670, caller of frame at 0x7f201842f600
 Arglist at 0x7f201842f5f8, args:
 Locals at 0x7f201842f5f8, Previous frame's sp is 0x7f201842f620
 Saved registers:
  rbx at 0x7f201842f600, rbp at 0x7f201842f608, r12 at 0x7f201842f610, rip at 0x7f201842f618
(gdb) up
#2  0x00000000004d8bfe in boost::fibers::context::terminate() ()
(gdb) info f
Stack level 2, frame at 0x7f201842f670:
 rip = 0x4d8bfe in boost::fibers::context::terminate(); saved rip = 0x522012
 called by frame at 0x7f201842f780, caller of frame at 0x7f201842f620
 Arglist at 0x7f201842f618, args:
 Locals at 0x7f201842f618, Previous frame's sp is 0x7f201842f670
 Saved registers:
  rbx at 0x7f201842f638, rbp at 0x7f201842f640, r12 at 0x7f201842f648, r13 at 0x7f201842f650, r14 at 0x7f201842f658, r15 at 0x7f201842f660, rip at 0x7f201842f668
(gdb) info locals
No symbol table info available.
(gdb) up
#3  0x0000000000522012 in boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&) (this=0x7f201842f900, c=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:437
437             return terminate();
(gdb) f
#3  0x0000000000522012 in boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&) (this=0x7f201842f900, c=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:437
437             return terminate();
(gdb) info f
Stack level 3, frame at 0x7f201842f780:
 rip = 0x522012 in boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&)
    (/root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:437); saved rip = 0x51de5b
 called by frame at 0x7f201842f7c0, caller of frame at 0x7f201842f670
 source language c++.
 Arglist at 0x7f201842f668, args: this=0x7f201842f900, c=...
 Locals at 0x7f201842f668, Previous frame's sp is 0x7f201842f780
 Saved registers:
  rbx at 0x7f201842f748, rbp at 0x7f201842f750, r12 at 0x7f201842f758, r13 at 0x7f201842f760, r14 at 0x7f201842f768, r15 at 0x7f201842f770, rip at 0x7f201842f778
(gdb) info locals
No locals.
(gdb) info args
this = 0x7f201842f900
c = <optimized out>
(gdb) up
#4  0x000000000051de5b in std::__invoke_impl<boost::context::fiber, boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__t=<optimized out>, __f=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:73
73            return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...);
(gdb) info f
Stack level 4, frame at 0x7f201842f7c0:
 rip = 0x51de5b
    in std::__invoke_impl<boost::context::fiber, boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:73); saved rip = 0x4dcd4f
 inlined into frame 5, caller of frame at 0x7f201842f780
 source language c++.
 Arglist at unknown address.
 Locals at unknown address, Previous frame's sp is 0x7f201842f780
 Saved registers:
  rbx at 0x7f201842f748, rbp at 0x7f201842f750, r12 at 0x7f201842f758, r13 at 0x7f201842f760, r14 at 0x7f201842f768, r15 at 0x7f201842f770, rip at 0x7f201842f778
(gdb) info locals
No locals.
(gdb) q
@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 7, 2018


I will rebuild boost with -g, and test again

this is with boost with symbol info,
#3 boost::fibers::context::suspend_with_cc (this=0x0) at libs/fiber/src/context.cpp:229
this is 0x0

I think this is a another problem, Not related to the patch


[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./ws_call_server'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  std::__exchange<void*, decltype(nullptr)>(void*&, decltype(nullptr)&&) (__new_val=<optimized out>, __obj=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/move.h:150
150           _Tp __old_val = std::move(__obj);
[Current thread is 1 (Thread 0x7f195024f700 (LWP 28305))]
Missing separate debuginfos, use: debuginfo-install glibc-2.17-222.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-19.el7.x86_64 libcom_err-1.42.9-11.el7.x86_64 libgcc-4.8.5-28.el7.x86_64 libselinux-2.5-12.el7.x86_64 libstdc++-4.8.5-28.el7.x86_64 openssl-libs-1.0.2k-12.el7.x86_64 pcre-8.32-17.el7.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) bt
#0  std::__exchange<void*, decltype(nullptr)>(void*&, decltype(nullptr)&&) (__new_val=<optimized out>, __obj=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/move.h:150
#1  std::exchange<void*, decltype(nullptr)>(void*&, decltype(nullptr)&&) (__new_val=<optimized out>, __obj=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/utility:282
#2  boost::context::fiber::resume_with<boost::fibers::context::suspend_with_cc()::<lambda(boost::context::fiber&&)> > (fn=..., this=<optimized out>) at ./boost/context/fiber_fcontext.hpp:293
#3  boost::fibers::context::suspend_with_cc (this=0x0) at libs/fiber/src/context.cpp:229
#4  0x00000000004dbf64 in boost::fibers::scheduler::terminate (this=0x7f19480009b0, lk=..., ctx=ctx@entry=0x7f194ad69000) at libs/fiber/src/scheduler.cpp:258
#5  0x00000000004d8bfe in boost::fibers::context::terminate (this=this@entry=0x7f194ad69000) at libs/fiber/src/context.cpp:253
#6  0x0000000000522012 in boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::run_(boost::context::fiber &&) (this=0x7f194ad69000, c=...)
    at /root/git_abc/server_kit/src/web_tool/../../include/boost/fiber/context.hpp:437
#7  0x000000000051de5b in std::__invoke_impl<boost::context::fiber, boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__t=<optimized out>, __f=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:73
#8  std::__invoke<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*&)(boost::context::fiber&&), boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*&, boost::context::fiber> (__fn=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/invoke.h:96
#9  std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::__call<boost::context::fiber, boost::context::fiber&&, 0, 1> (__args=..., this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:469
#10 std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>::operator()<boost::context::fiber> (this=<optimized out>) at /opt/rh/devtoolset-7/root/usr/include/c++/7/functional:551
#11 boost::context::detail::invoke<std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)>&, boost::context::fiber> (fn=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/detail/invoke.hpp:41
#12 boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> >::run (fctx=<optimized out>,
    this=<optimized out>, this=<optimized out>, this=<optimized out>) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:139
#13 boost::context::detail::fiber_entry<boost::context::detail::fiber_record<boost::context::fiber, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<boost::context::fiber (boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >::*(boost::fibers::worker_context<WsCallServer::session(SocketPtr)::<lambda()> >*, std::_Placeholder<1>))(boost::context::fiber&&)> > >(boost::context::detail::transfer_t) (t=...) at /root/git_abc/server_kit/src/web_tool/../../include/boost/context/fiber_fcontext.hpp:80
#14 0x00000000004dcd4f in make_fcontext () at libs/context/src/asm/make_x86_64_sysv_elf_gas.S:70
#15 0x0000000000000000 in ?? ()

@olk

This comment has been minimized.

Member

olk commented Jun 13, 2018

could you provide a test app that triggers this issue, please?

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 13, 2018

test case
https://github.com/jxfwinter/stress_test

sometimes it appeared with 4 hours to run,If you want to appear early,running test,simultaneously, compiling on the same computer, such as compiling boost or make -j6, take cpu resources as much as possible。
if my code has error, please tell me, thank you.

@olk

This comment has been minimized.

Member

olk commented Jun 13, 2018

Ty, I see that it uses boost::asio::io_context ... the integration with boost.asio is problematic ...

@jxfwinter

This comment has been minimized.

jxfwinter commented Jun 13, 2018

scheduler.cpp
line 236

boost::context::fiber
scheduler::terminate( detail::spinlock_lock & lk, context * ctx) noexcept {
    BOOST_ASSERT( nullptr != ctx);
    BOOST_ASSERT( context::active() == ctx);
    BOOST_ASSERT( this == ctx->get_scheduler() );
    BOOST_ASSERT( ctx->is_context( type::worker_context) );
    BOOST_ASSERT( ! ctx->is_context( type::pinned_context) );
    BOOST_ASSERT( ! ctx->ready_is_linked() );
#if ! defined(BOOST_FIBERS_NO_ATOMICS)
    BOOST_ASSERT( ! ctx->remote_ready_is_linked() );
#endif
    BOOST_ASSERT( ! ctx->sleep_is_linked() );
    BOOST_ASSERT( ! ctx->terminated_is_linked() );
    BOOST_ASSERT( ! ctx->wait_is_linked() );
    BOOST_ASSERT( ctx->wait_queue_.empty() );
    // store the terminated fiber in the terminated-queue
    // the dispatcher-context will call
    ctx->terminated_link( terminated_queue_);
    // remove from the worker-queue
    ctx->worker_unlink();
    // release lock
    lk.unlock();
    // resume another fiber
    return algo_->pick_next()->suspend_with_cc(); //algo_->pick_next() will not nullptr ?
}
@olk

This comment has been minimized.

Member

olk commented Jun 13, 2018

algo_->pick_next() should always return a valid fiber
if no worker-fiber (created by user-code) is ready, the dispatcher-fiber should be returned (dispatcher-fiber does some houskeeping, is always enqueued in ready-queue)

@jxfwinter jxfwinter closed this Jun 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment