|
Boost Users : |
From: Senthil Cheetancheri (scheetancheri_at_[hidden])
Date: 2021-11-11 00:19:25
Hi,
I'm learning to use Boost.asio by going through the tutorials at [1].
However, the listing for "Synchronizing handlers in multithreaded programs" crashes on my Ubuntu. Source listing (about 70 lines) is at [2]. I have given my compilation steps, stack trace from gdb, and boost information below. Can you please advise how I can get this working right?
[1] https://www.boost.org/doc/libs/1_77_0/doc/html/boost_asio/tutorial.html
[2] https://www.boost.org/doc/libs/1_77_0/doc/html/boost_asio/tutorial/tuttimer5/src.html
I compiled and ran as follows:
$ g++ -g -o timer_5.1 timer_5.1.cpp -lpthread -lboost_thread
$ ./timer_5.1
Timer 1: 0
Timer 2: 1
Timer 1: 2
Timer 2: 3
Timer 1: 4
Timer 2: 5
Timer 1: 6
Timer 2: 7
Timer 1: 8
Timer 2: 9
Segmentation fault (core dumped)
The backtrace from gdb is:
$ cat gdb_log.txt
#0 0x00007ffff799f88b in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1
#1 0x00007ffff79a0bd5 in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1
#2 0x00007ffff7bbb6db in start_thread (arg=0x7ffff6851700) at pthread_create.c:463
#3 0x00007ffff711e71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
I have the following boost library installed:
$ sudo apt show libboost-all-dev
Package: libboost-all-dev
Version: 1.65.1.0ubuntu1
Priority: optional
Section: universe/libdevel
Source: boost-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss_at_[hidden]>
Original-Maintainer: Debian Boost Team <pkg-boost-devel_at_[hidden]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 10.2 kB
Depends: libboost-dev, libboost-tools-dev, libboost-atomic-dev, libboost-chrono-dev, libboost-container-dev, libboost-context-dev, libboost-coroutine-dev, libboost-date-time-dev, libboost-exception-dev, libboost-fiber-dev, libboost-filesystem-dev, libboost-graph-dev, libboost-graph-parallel-dev, libboost-iostreams-dev, libboost-locale-dev, libboost-log-dev, libboost-math-dev, libboost-mpi-dev, libboost-mpi-python-dev, libboost-numpy-dev, libboost-program-options-dev, libboost-python-dev, libboost-random-dev, libboost-regex-dev, libboost-serialization-dev, libboost-signals-dev, libboost-stacktrace-dev, libboost-system-dev, libboost-test-dev, libboost-thread-dev, libboost-timer-dev, libboost-type-erasure-dev, libboost-wave-dev
Homepage: http://www.boost.org/
Download-Size: 2,340 B
APT-Manual-Installed: yes
. . .
Thanks in advance.
Thanks,
Senthil.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net