You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Jiri Daněk (JIRA)" <ji...@apache.org> on 2017/10/23 11:57:00 UTC
[jira] [Created] (PROTON-1648) Creating proton::work from
proton::void_function0 can lead to segfault; does not compile when mixing
C++03 and 11
Jiri Daněk created PROTON-1648:
----------------------------------
Summary: Creating proton::work from proton::void_function0 can lead to segfault; does not compile when mixing C++03 and 11
Key: PROTON-1648
URL: https://issues.apache.org/jira/browse/PROTON-1648
Project: Qpid Proton
Issue Type: Bug
Components: cpp-binding
Reporter: Jiri Daněk
Assignee: Cliff Jansen
When both proton and the code below is compiled with the same c++ release, it segfaults. If library is c++11 and the code is c++03, then the following compilation error appears
{noformat}
../proton-c/bindings/cpp/src/container_test.cpp: In member function ‘virtual void {anonymous}::deprecated_schedule_tester::on_container_start(proton::container&)’:
../proton-c/bindings/cpp/src/container_test.cpp:687:44: error: no matching function for call to ‘proton::internal::v03::work::work({anonymous}::deprecated_schedule_tester::timer_event_t&)’
proton::work timer_work(timer_event); // lib: c++11, this file: c++98:: does not compile; this AFAIC used to work
{noformat}
{code}
struct deprecated_schedule_tester : public proton::messaging_handler {
int scheduled_work;
struct timer_event_t : public proton::void_function0 {
deprecated_schedule_tester &parent;
timer_event_t(deprecated_schedule_tester &handler) : parent(handler) {}
void operator()() PN_CPP_OVERRIDE {
parent.scheduled_work++;
}
};
deprecated_schedule_tester() : scheduled_work(0) {}
void on_container_start(proton::container& c) PN_CPP_OVERRIDE {
timer_event_t timer_event(*this);
proton::work timer_work(timer_event); // lib: c++11, this file: c++98:: does not compile; this AFAIC used to work
proton::duration d1(1 * proton::duration::SECOND.milliseconds());
proton::duration d2(2 * proton::duration::SECOND.milliseconds());
c.schedule(d1, timer_work); // works
c.schedule(d2, timer_event); // if timer_work exists, this segfaults
}
};
int test_container_schedule_deprecated() {
deprecated_schedule_tester t;
proton::container c(t);
c.run();
ASSERT_EQUAL(2, t.scheduled_work);
return 0;
}
{code}
{noformat}
rogram received signal SIGSEGV, Segmentation fault.
0x00007ffff7b65109 in std::__invoke_impl<void, void (proton::void_function0::*&)(), proton::void_function0*&> (__t=<optimized out>, __f=<optimized out>) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/bits/invoke.h:73
73 return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...);
(gdb) bt
#0 0x00007ffff7b65109 in std::__invoke_impl<void, void (proton::void_function0::*&)(), proton::void_function0*&> (__t=<optimized out>, __f=<optimized out>) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/bits/invoke.h:73
#1 std::__invoke<void (proton::void_function0::*&)(), proton::void_function0*&> (__fn=<optimized out>) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/bits/invoke.h:95
#2 std::_Bind<void (proton::void_function0::*(proton::void_function0*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) (__args=<optimized out>, this=<optimized out>) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/functional:461
#3 std::_Bind<void (proton::void_function0::*(proton::void_function0*))()>::operator()<, void>() (this=<optimized out>) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/functional:545
#4 std::_Function_handler<void (), std::_Bind<void (proton::void_function0::*(proton::void_function0*))()> >::_M_invoke(std::_Any_data const&) (__functor=...) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/bits/std_function.h:316
#5 0x00007ffff7b696a1 in std::function<void ()>::operator()() const (this=0x7fffffffcbb0) at /nix/store/f8l8z14kniqk8k4k7qbf9pacnjjfsqcv-gcc-7-20170409/include/c++/7.0.1/bits/std_function.h:706
#6 proton::internal::v11::work::operator() (this=0x7fffffffcbb0) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/include/proton/work_queue.hpp:289
#7 proton::container::impl::run_timer_jobs (this=this@entry=0x61d030) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/proactor_container_impl.cpp:454
#8 0x00007ffff7b6a385 in proton::container::impl::handle (this=this@entry=0x61d030, event=<optimized out>) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/proactor_container_impl.cpp:485
#9 0x00007ffff7b6aab3 in proton::container::impl::thread (this=this@entry=0x61d030) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/proactor_container_impl.cpp:633
#10 0x00007ffff7b6b1a3 in proton::container::impl::run (this=0x61d030, threads=threads@entry=1) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/proactor_container_impl.cpp:675
#11 0x00007ffff7b64229 in proton::container::run (this=this@entry=0x7fffffffcf38) at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/container.cpp:88
#12 0x0000000000403d45 in (anonymous namespace)::test_container_schedule_deprecated () at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/container_test.cpp:701
#13 0x00000000004030a2 in main () at /home/jdanek/Work/repos/qpid-proton/proton-c/bindings/cpp/src/container_test.cpp:711
#14 0x00007ffff6a6b560 in __libc_start_main () from /nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib/libc.so.6
#15 0x000000000040342a in _start () at ../sysdeps/x86_64/start.S:120
{noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org