Error message [Segmentation fault (core dumped)]

655 views
Skip to first unread message

obinna Igbe

unread,
Aug 13, 2015, 4:19:47 PM8/13/15
to automatak-dnp3
Hi,

I successfully compiled this branch on my Ubuntu 14.0, and after making few changes (IP address) to the DemoMain.cpp file in the examples\master folder,I tried running the executable. But when the master tries to connect to the outstation; whose IP I also changed, I get the ERROR in the master:

channel state: CLOSED
channel state: OPENING
Segmentation fault (core dumped)
 

What might have caused this, and how do I resolve it. Thanks.



Screenshot from 2015-08-13 16:11:10.png

Adam Crain

unread,
Aug 13, 2015, 8:32:11 PM8/13/15
to automatak-dnp3
Hi,

Unfortunately, there's no way to debug a run-time failure like this without more information. I would compile with debug information and run your program with GDB or a GDB frontend like the one in KDevelop. I have to know where it is seg faulting to have any chance of helping.

Two questions:

1) What version of the code is this? I am assuming the last stable release tag unless I am told otherwise,  i.e. 2.0.1.

2) Have you made any other modifications to the demo's other than altering IP addresses?

thanks,
Adam

obinna Igbe

unread,
Aug 14, 2015, 12:59:41 AM8/14/15
to automatak-dnp3
Yes Adam its the 2.0.1, I have not made any other modification apart from the IP address.

obinna Igbe

unread,
Aug 14, 2015, 1:01:12 AM8/14/15
to automatak-dnp3
And by the way, It compiled successfully, just that when i run the demo, the oustation appears ok, but when the master comes up and tries to connect, I get the seg fault error.


On Thursday, August 13, 2015 at 8:32:11 PM UTC-4, Adam Crain wrote:

Adam Crain

unread,
Aug 14, 2015, 5:25:55 PM8/14/15
to automatak-dnp3
Ok, thanks for that info.

I am eager to help you because the stack shouldn't crash now matter what you enter for the IP address, but to help further I will at least need some kind of stack trace or a copy of your program.

-Adam

obinna Igbe

unread,
Aug 15, 2015, 11:58:12 AM8/15/15
to automatak-dnp3
Hi Adam find attached the codes I modified with the IP address change.
MasterDemoMain.cpp
OutstationDemoMain.cpp

J Adam Crain

unread,
Aug 16, 2015, 11:30:31 PM8/16/15
to automatak-dnp3
Thanks Obinna. As you told me, this is just a changed IP.  Given that I can't replicate, can you try recompiling with debug symbols and running the master using GDB to try and get a stack trace?

I think it would go something like this, but lease look up an online guide for gdb:

> autoreconf -i -f
> ./configure CXX_FLAGS="-g -O0"
> make
> gdb masterdemo

When the master connects and crashes you should get a lot more info including a stack trace.

-Adam

obinna Igbe

unread,
Aug 17, 2015, 2:57:40 AM8/17/15
to automatak-dnp3
Hi Adam,

I compile with the gdb below is the output


Reading symbols from DemoMain...done.
[New LWP 30473]
[New LWP 30475]
[New LWP 30474]
[New LWP 30477]
[New LWP 30476]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./DemoMain'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000608350 in vtable for __cxxabiv1::__class_type_info@@CXXABI_1.3
   ()
(gdb)

Then I used bt to get a back track below:

(gdb) bt
#0  0x0000000000608350 in vtable for __cxxabiv1::__class_type_info@@CXXABI_1.3
   ()
#1  0x0000000000403678 in main (argc=1, argv=0x7ffebe005ac8) at DemoMain.cpp:97

Note the DemoMain.cpp:97 would correspond to the same line number in the file: https://github.com/automatak/dnp3/blob/2.0.x/cpp/examples/master/DemoMain.cpp

Thanks in anticipation of your reply.


Obinna

Adam Crain

unread,
Aug 17, 2015, 6:10:13 AM8/17/15
to automatak-dnp3
We're getting closer. I suspect that it is actually faulting on a background thread. Try using the command:

thread apply all backtrace


This should give us a stacktrace for every thread.

obinna Igbe

unread,
Aug 17, 2015, 9:24:52 AM8/17/15
to automatak-dnp3
this is the output off running thread apply all backtrace

(gdb) thread apply all backtrace

Thread 5 (Thread 0x7f8e8071a700 (LWP 30476)):
#0  0x00007f8e81b1db13 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f8e82541e68 in asio::detail::epoll_reactor::run (this=0x19117e0, block=<optimized out>, ops=...)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/epoll_reactor.ipp:391
#2  0x00007f8e8253fc67 in do_run_one (ec=..., this_thread=..., lock=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:355
#3  run (ec=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x1911568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x1911500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f8e822cdbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f8e81df0182 in start_thread (arg=0x7f8e8071a700) at pthread_create.c:312
#8  0x00007f8e81b1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 4 (Thread 0x7f8e7ff19700 (LWP 30477)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f8e8253fdaa in wait<asio::detail::scoped_lock<asio::detail::posix_mutex> > (lock=..., this=0x19116e8)
    at /users/oigbe000/asio/asio/include/asio/detail/posix_event.hpp:105
#2  do_run_one (ec=..., this_thread=..., lock=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:379
#3  run (ec=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x1911568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x1911500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f8e822cdbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f8e81df0182 in start_thread (arg=0x7f8e7ff19700) at pthread_create.c:312
#8  0x00007f8e81b1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7f8e8171c700 (LWP 30474)):
#0  0x00007f8e81b0e88d in write () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f8e81a9c003 in _IO_new_file_write (f=0x7f8e81de2400 <_IO_2_1_stdout_>, data=0x7f8e830db000, n=53) at fileops.c:1261
#2  0x00007f8e81a9d4dc in new_do_write (to_do=53, data=0x7f8e830db000 "ms(1439793963442) INFO tcpclient - Connected to host\n", fp=0x7f8e81de2400 <_IO_2_1_stdout_>)
    at fileops.c:538
#3  _IO_new_do_write (fp=fp@entry=0x7f8e81de2400 <_IO_2_1_stdout_>, data=0x7f8e830db000 "ms(1439793963442) INFO tcpclient - Connected to host\n", to_do=53)
    at fileops.c:511
#4  0x00007f8e81a9d8b3 in _IO_new_file_overflow (f=0x7f8e81de2400 <_IO_2_1_stdout_>, ch=10) at fileops.c:876
#5  0x00007f8e81a95009 in __GI__IO_putc (c=<optimized out>, fp=0x7f8e81de2400 <_IO_2_1_stdout_>) at putc.c:31
#6  0x00007f8e822b0834 in std::ostream::put(char) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f8e829b1962 in endl<char, std::char_traits<char> > (__os=...) at /usr/include/c++/4.8/ostream:565
#8  operator<< (__pf=<optimized out>, this=0x6083a0 <std::cout@@GLIBCXX_3.4>) at /usr/include/c++/4.8/ostream:113
#9  asiodnp3::ConsoleLogger::Log (this=<optimized out>, entry=...) at cpp/libs/asiodnp3/src/asiodnp3/ConsoleLogger.cpp:71
#10 0x00007f8e82543ddc in asiopal::LogFanoutHandler::Log (this=<optimized out>, entry=...) at cpp/libs/asiopal/src/asiopal/LogFanoutHandler.cpp:35
#11 0x00007f8e82771783 in openpal::LogRoot::Log (this=0x1911450, filters=..., 
    location=location@entry=0x7f8e825630f8 "cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp(129)", message=message@entry=0x7f8e825630ba "Connected to host", 
    errorCode=errorCode@entry=-1) at cpp/libs/openpal/src/openpal/logging/LogRoot.cpp:60
---Type <return> to continue, or q <return> to quit---
#12 0x00007f8e827716ec in openpal::Logger::Log (this=this@entry=0x19120e0, filters=..., 
    location=location@entry=0x7f8e825630f8 "cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp(129)", message=message@entry=0x7f8e825630ba "Connected to host", 
    errorCode=errorCode@entry=-1) at cpp/libs/openpal/src/openpal/logging/Logger.cpp:45
#13 0x00007f8e82552c5b in asiopal::PhysicalLayerTCPClient::DoOpenSuccess (this=0x19120d0) at cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp:129
#14 0x00007f8e82544805 in asiopal::PhysicalLayerBase::OnOpenCallback (this=0x19120d0, err=...) at cpp/libs/asiopal/src/asiopal/PhysicalLayerBase.cpp:280
#15 0x00007f8e825530b5 in operator() (code=..., __closure=0x7f8e8171bb70) at cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp:83
#16 operator() (this=0x7f8e8171bb70) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:46
#17 asio_handler_invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (function=...)
    at /users/oigbe000/asio/asio/include/asio/handler_invoke_hook.hpp:68
#18 invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (
    context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#19 asio_handler_invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> (this_handler=<optimized out>, function=...) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:87
#20 invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#21 asio::detail::strand_service::dispatch<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> >(asio::detail::strand_service::implementation_type &, asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> &) (this=0x19122b0, impl=@0x7f8e8171bba0: 0x1912920, 
    handler=...) at /users/oigbe000/asio/asio/include/asio/detail/impl/strand_service.hpp:61
#22 0x00007f8e825533af in dispatch<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (handler=<optimized out>, 
    this=0x7f8e8171bb98) at /users/oigbe000/asio/asio/include/asio/strand.hpp:157
#23 operator()<std::error_code> (arg1=..., this=0x7f8e8171bb98) at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:86
#24 operator() (this=0x7f8e8171bb98) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:46
#25 operator() (this=0x7f8e8171bb90) at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:190
#26 asio_handler_invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (function=...)
    at /users/oigbe000/asio/asio/include/asio/handler_invoke_hook.hpp:68
#27 invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#28 asio_handler_invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (this_handler=<optimized out>, function=...) at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:274
#29 invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#30 asio::detail::completion_handler<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> >::do_complete(asio::detail::io_service_impl *, asio::detail::operation *, const asio::error_code &, std::size_t) (owner=owner@entry=0x1911690, base=base@entry=0x7f8e74000960)
    at /users/oigbe000/asio/asio/include/asio/detail/completion_handler.hpp:67
#31 0x00007f8e8255361a in asio::detail::strand_service::dispatch<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::str---
and, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> >(asio::detail::strand_service::implementation_type &, asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> &) (this=0x19122b0, impl=@0x7f8e8171bc98: 0x1912920, handler=...) at /users/oigbe000/asio/asio/include/asio/detail/impl/strand_service.hpp:87
#32 0x00007f8e825538cd in dispatch<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (
    handler=<optimized out>, this=0x7f8e8171bc90) at /users/oigbe000/asio/asio/include/asio/strand.hpp:157
#33 asio_handler_invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>
    (this_handler=0x7f8e8171bc90, function=...) at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:231
#34 invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running> > (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#35 asio_handler_invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code> (this_handler=0x7f8e8171bc90, function=...) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:87
#36 invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code> > (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#37 asio::detail::reactive_socket_connect_op<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running> >::do_complete(asio::detail::io_service_impl *, asio::detail::operation *, const asio::error_code &, std::size_t) (owner=0x1911690, 
    base=0x7f8e74000960) at /users/oigbe000/asio/asio/include/asio/detail/reactive_socket_connect_op.hpp:92
#38 0x00007f8e82551b34 in complete (bytes_transferred=0, ec=..., owner=..., this=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/task_io_service_operation.hpp:37
#39 asio::detail::epoll_reactor::descriptor_state::do_complete (owner=0x1911690, base=<optimized out>, ec=..., bytes_transferred=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/epoll_reactor.ipp:650
#40 0x00007f8e8253fead in complete (bytes_transferred=4, ec=..., owner=..., this=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/task_io_service_operation.hpp:37
#41 do_run_one (ec=..., this_thread=..., lock=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:371
#42 run (ec=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#43 run (this=0x1911568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#44 asiopal::IOServiceThreadPool::Run (this=0x1911500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#45 0x00007f8e822cdbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#46 0x00007f8e81df0182 in start_thread (arg=0x7f8e8171c700) at pthread_create.c:312
#47 0x00007f8e81b1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 2 (Thread 0x7f8e80f1b700 (LWP 30475)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f8e8253fdaa in wait<asio::detail::scoped_lock<asio::detail::posix_mutex> > (lock=..., this=0x19116e8)
    at /users/oigbe000/asio/asio/include/asio/detail/posix_event.hpp:105
#2  do_run_one (ec=..., this_thread=..., lock=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:379
#3  run (ec=..., this=0x1911690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x1911568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x1911500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f8e822cdbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f8e81df0182 in start_thread (arg=0x7f8e80f1b700) at pthread_create.c:312
#8  0x00007f8e81b1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7f8e830cd780 (LWP 30473)):
#0  0x0000000000608350 in vtable for __cxxabiv1::__class_type_info@@CXXABI_1.3 ()
#1  0x0000000000403678 in main (argc=1, argv=0x7ffebe005ac8) at DemoMain.cpp:97
(gdb) 




obinna Igbe

unread,
Aug 17, 2015, 11:41:54 PM8/17/15
to automatak-dnp3
Hi Adam,
Did you get an opportunity to look at the trace?

J Adam Crain

unread,
Aug 18, 2015, 11:09:33 AM8/18/15
to automatak-dnp3
I did, but I'm currently stumped.

Can you try one thing for me? Turn the number of threads in the thread pool down to 1.

i.e. replace:

DNP3Manager manager(std::thread::hardware_concurrency());

with

DNP3Manager manager(1);

There should be way fewer threads when running gdb. Send back the stack trace again please.

obinna Igbe

unread,
Aug 18, 2015, 8:21:08 PM8/18/15
to automatak-dnp3
Modifying the code as you suggested above gave the following stack trace:

Thread 5 (Thread 0x7f5ad25a8700 (LWP 28250)):
#0  0x00007f5ad41acb13 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f5ad4bd0e68 in asio::detail::epoll_reactor::run (this=0x19c77e0, block=<optimized out>, ops=...)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/epoll_reactor.ipp:391
#2  0x00007f5ad4bcec67 in do_run_one (ec=..., this_thread=..., lock=..., this=0x19c7690)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:355
#3  run (ec=..., this=0x19c7690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x19c7568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x19c7500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f5ad495cbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f5ad447f182 in start_thread (arg=0x7f5ad25a8700) at pthread_create.c:312
#8  0x00007f5ad41ac47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 4 (Thread 0x7f5ad35aa700 (LWP 28248)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f5ad4bcedaa in wait<asio::detail::scoped_lock<asio::detail::posix_mutex> > (lock=..., this=0x19c76e8)
    at /users/oigbe000/asio/asio/include/asio/detail/posix_event.hpp:105
#2  do_run_one (ec=..., this_thread=..., lock=..., this=0x19c7690)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:379
#3  run (ec=..., this=0x19c7690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x19c7568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x19c7500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f5ad495cbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f5ad447f182 in start_thread (arg=0x7f5ad35aa700) at pthread_create.c:312
#8  0x00007f5ad41ac47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7f5ad3dab700 (LWP 28247)):
#0  0x00007f5ad4919940 in std::ios_base::_M_init() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007f5ad49279a1 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)
    () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007f5ad5040693 in basic_ostream (__vtt_parm=<optimized out>, this=0x7f5ad3daa790, __in_chrg=<optimized out>)
    at /usr/include/c++/4.8/ostream:385
#3  basic_ostringstream (__mode=std::_S_out, this=0x7f5ad3daa790, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /usr/include/c++/4.8/sstream:424
#4  asiodnp3::ConsoleLogger::Log (this=0x608300 <asiodnp3::ConsoleLogger::instance>, entry=...)
    at cpp/libs/asiodnp3/src/asiodnp3/ConsoleLogger.cpp:55
#5  0x00007f5ad4bd2ddc in asiopal::LogFanoutHandler::Log (this=<optimized out>, entry=...)
    at cpp/libs/asiopal/src/asiopal/LogFanoutHandler.cpp:35
#6  0x00007f5ad4e00783 in openpal::LogRoot::Log (this=0x19c7450, filters=..., 
    location=location@entry=0x7f5ad4bf20f8 "cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp(129)", 
    message=message@entry=0x7f5ad4bf20ba "Connected to host", errorCode=errorCode@entry=-1)
    at cpp/libs/openpal/src/openpal/logging/LogRoot.cpp:60
#7  0x00007f5ad4e006ec in openpal::Logger::Log (this=this@entry=0x19c80e0, filters=..., 
    location=location@entry=0x7f5ad4bf20f8 "cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp(129)", 
    message=message@entry=0x7f5ad4bf20ba "Connected to host", errorCode=errorCode@entry=-1)
    at cpp/libs/openpal/src/openpal/logging/Logger.cpp:45
#8  0x00007f5ad4be1c5b in asiopal::PhysicalLayerTCPClient::DoOpenSuccess (this=0x19c80d0)
    at cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp:129
#9  0x00007f5ad4bd3805 in asiopal::PhysicalLayerBase::OnOpenCallback (this=0x19c80d0, err=...)
    at cpp/libs/asiopal/src/asiopal/PhysicalLayerBase.cpp:280
#10 0x00007f5ad4be20b5 in operator() (code=..., __closure=0x7f5ad3daab70)
    at cpp/libs/asiopal/src/asiopal/PhysicalLayerTCPClient.cpp:83
#11 operator() (this=0x7f5ad3daab70) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:46
#12 asio_handler_invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (
    function=...) at /users/oigbe000/asio/asio/include/asio/handler_invoke_hook.hpp:68
#13 invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (context=..., function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#14 asio_handler_invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> (this_handler=<optimized out>, function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:87
#15 invoke<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code>, asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (context=..., function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#16 asio::detail::strand_service::dispatch<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_co
de> >(asio::detail::strand_service::implementation_type &, asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> &) (this=0x19c82b0, impl=@0x7f5ad3daaba0: 0x19c8920, handler=...)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/strand_service.hpp:61
#17 0x00007f5ad4be23af in dispatch<asio::detail::binder1<asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, std::error_code> > (
    handler=<optimized out>, this=0x7f5ad3daab98) at /users/oigbe000/asio/asio/include/asio/strand.hpp:157
#18 operator()<std::error_code> (arg1=..., this=0x7f5ad3daab98)
    at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:86
#19 operator() (this=0x7f5ad3daab98) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:46
#20 operator() (this=0x7f5ad3daab90) at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:190
#21 asio_handler_invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (function=...) at /users/oigbe000/asio/asio/include/asio/handler_invoke_hook.hpp:68
#22 invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (context=..., function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#23 asio_handler_invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> (this_handler=<optimized out>, function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:274
#24 invoke<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5>, asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (context=..., function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#25 asio::detail::completion_handler<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> >::do_complete(asio::detail::io_service_impl *, asio::detail::operation *, const asio::error_code &, std::size_t) (owner=owner@entry=0x19c7690, base=base@entry=0x7f5ac8000960)
    at /users/oigbe000/asio/asio/include/asio/detail/completion_handler.hpp:67
#26 0x00007f5ad4be261a in asio::detail::strand_service::dispatch<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> >(asio::detail::strand_service::implementation_type &, asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> &) (this=0x19c82b0, impl=@0x7f5ad3daac98: 0x19c8920, handler=...)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/strand_service.hpp:87
#27 0x00007f5ad4be28cd in dispatch<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5> > (handler=<optimized out>, this=0x7f5ad3daac90)
    at /users/oigbe000/asio/asio/include/asio/strand.hpp:157
#28 asio_handler_invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running> (this_handler=0x7f5ad3daac90, function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/wrapped_handler.hpp:231
#29 invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running> > (context=..., function=...)
    at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#30 asio_handler_invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code> (
    this_handler=0x7f5ad3daac90, function=...) at /users/oigbe000/asio/asio/include/asio/detail/bind_handler.hpp:87
#31 invoke<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code>, asio::detail::binder1<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running>, std::error_code> > (context=..., function=...) at /users/oigbe000/asio/asio/include/asio/detail/handler_invoke_helpers.hpp:37
#32 asio::detail::reactive_socket_connect_op<asio::detail::wrapped_handler<asio::io_service::strand, asiopal::PhysicalLayerTCPClient::DoOpen()::__lambda5, asio::detail::is_continuation_if_running> >::do_complete(asio::detail::io_service_impl *, asio::detail::operation *, const asio::error_code &, std::size_t) (owner=0x19c7690, base=0x7f5ac8000960)
    at /users/oigbe000/asio/asio/include/asio/detail/reactive_socket_connect_op.hpp:92
#33 0x00007f5ad4be0b34 in complete (bytes_transferred=0, ec=..., owner=..., this=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/task_io_service_operation.hpp:37
    at /users/oigbe000/asio/asio/include/asio/detail/reactive_socket_connect_op.hpp:92
#33 0x00007f5ad4be0b34 in complete (bytes_transferred=0, ec=..., owner=..., this=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/task_io_service_operation.hpp:37
#34 asio::detail::epoll_reactor::descriptor_state::do_complete (owner=0x19c7690, base=<optimized out>, ec=..., 
    bytes_transferred=<optimized out>) at /users/oigbe000/asio/asio/include/asio/detail/impl/epoll_reactor.ipp:650
#35 0x00007f5ad4bceead in complete (bytes_transferred=4, ec=..., owner=..., this=<optimized out>)
    at /users/oigbe000/asio/asio/include/asio/detail/task_io_service_operation.hpp:37
#36 do_run_one (ec=..., this_thread=..., lock=..., this=0x19c7690)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:371
#37 run (ec=..., this=0x19c7690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#38 run (this=0x19c7568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#39 asiopal::IOServiceThreadPool::Run (this=0x19c7500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#40 0x00007f5ad495cbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#41 0x00007f5ad447f182 in start_thread (arg=0x7f5ad3dab700) at pthread_create.c:312
#42 0x00007f5ad41ac47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 2 (Thread 0x7f5ad2da9700 (LWP 28249)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f5ad4bcedaa in wait<asio::detail::scoped_lock<asio::detail::posix_mutex> > (lock=..., this=0x19c76e8)
    at /users/oigbe000/asio/asio/include/asio/detail/posix_event.hpp:105
#2  do_run_one (ec=..., this_thread=..., lock=..., this=0x19c7690)
    at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:379
#3  run (ec=..., this=0x19c7690) at /users/oigbe000/asio/asio/include/asio/detail/impl/task_io_service.ipp:148
#4  run (this=0x19c7568) at /users/oigbe000/asio/asio/include/asio/impl/io_service.ipp:58
#5  asiopal::IOServiceThreadPool::Run (this=0x19c7500) at cpp/libs/asiopal/src/asiopal/IOServiceThreadPool.cpp:99
#6  0x00007f5ad495cbf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f5ad447f182 in start_thread (arg=0x7f5ad2da9700) at pthread_create.c:312
#8  0x00007f5ad41ac47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7f5ad575c780 (LWP 28246)):
#0  0x0000000000608350 in vtable for __cxxabiv1::__class_type_info@@CXXABI_1.3 ()
#1  0x0000000000403678 in main (argc=1, argv=0x7ffd4bc5eb18) at DemoMain.cpp:105

obinna Igbe

unread,
Aug 18, 2015, 11:18:07 PM8/18/15
to automatak-dnp3
Just in case if this will help you assist me, I am compiling the demo with the line below:

g++ --std=c++11 -o DemoMain DemoMain.cpp -lopendnp3 -lasiodnp3 -lopenpal -lasiopal -I/users/oigbe000/dnp3/cpp/libs/dnp3/ -I/users/oigbe000/asio/asio/include -I $ASIO_HOME -pthread -DASIO_STANDALONE

When I go to the dnp3 file (from where I compiled the open dnp3 library initially) and re-run the make and make install, the masterdemo in /usr/bin communicated well with an outstation DemoMain.cpp which was compiled with my line above.

Finding 1) The Outstation DemoMain.cpp compiled with my line above works perfectly ok. I.e this segfault only affects the master.

Finding 2) Compiling the master's DemoMain.cpp even without changes i.e leaving the 127.0.0.1 IP address, still caused a segfault when I tries initiating a communication to the Outstation

Question: What is it am missing in the msters's DemoMain.cpp compilation using the code above?

Thanks.
...

J Adam Crain

unread,
Aug 19, 2015, 8:56:02 AM8/19/15
to automatak-dnp3
I am beginning to wonder whether you might be linking against a different version than the one the demo is compiled against. Those linking commands will probably find the libraries install in /usr/lib.

Opendnp3 has not made an effort to preserve ABI compatibility, so things could fail during runtime if API things had changed sizes.
...

obinna Igbe

unread,
Aug 19, 2015, 12:29:12 PM8/19/15
to automatak-dnp3
You were right Adam. I have resolved it using your "Wonderings". I was probably linking against a different version like wondered. I had to use "git checkout 2.0.1" again just like I did when I built the library, and then compiled using the same code line, and it worked. Thanks for your help.


Regards,
Obinna

J Adam Crain

unread,
Aug 19, 2015, 12:49:52 PM8/19/15
to automatak-dnp3
Excellent. I'm glad, b/c I was all out of things to try.
Reply all
Reply to author
Forward
0 new messages