Open jjELT opened 3 years ago
Ran the test on two Linuxes, with different kernels, but the same result, so the problem seems to be unrelated to the kernel.
The tested distributions and kernels are:
Linux Mint 20.1: 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
CentOS 8.2: 4.18.0-193.19.1.el8_2.x86_64 #1 SMP Mon Sep 14 14:37:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Observation
On Linux, a thread, hanging in
boost::asio::serial_port::read_some
does notstd::thread::join
afterboost::asio::serial_port::close
is called from another thread.This applies to Boost v1.72.0 and v1.76.0 (other versions not tested).
The problem does not occur in Windows.
Sample Code
Starting a thread to synchronously read data from the serial port:
Closing the serial port in the main thread:
The line
LOG_TRACE(logger) << "Receiving thread finished.";
is never reached.Workaround
Detaching the thread
serves as a workaround.
On Linux the lines
are never reached though, contrary to Windows, where they are reached! So I guess the thread is just forcefully killed by the OS eventually?!
See logs: elt-cpp-core-test-app_LINUX.log elt-cpp-core-test-app_WINDOWS.log
Possibly Related
Could be related to #762 and #779.