From e66f87cf567b4af11752896bc2b399779b6d93f8 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 27 Jun 2021 09:27:51 +0300 Subject: [PATCH 1/3] force unbuffered stdout on running unit tests --- unit-tests/py/rspy/libci.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unit-tests/py/rspy/libci.py b/unit-tests/py/rspy/libci.py index 760cee8567..0342c7be2c 100644 --- a/unit-tests/py/rspy/libci.py +++ b/unit-tests/py/rspy/libci.py @@ -359,6 +359,9 @@ def command( self ): # -S : don't imply 'import site' on initialization # NOTE: exit() is defined in site.py and works only if the site module is imported! cmd += ['-S'] + # '-u' --> Force stdin, stdout and stderr to be totally unbuffered + # We saw that with stdout buffing, it a test would exit on an access violation, no log can be found since it was buffered. + cmd += ['-u'] if sys.flags.verbose: cmd += ["-v"] cmd += [self.path_to_script] From a3f5cd9613122d77aa0edede591c447074ad6c8d Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 27 Jun 2021 17:09:34 +0300 Subject: [PATCH 2/3] fix crash in playback distruction --- src/media/playback/playback_device.cpp | 17 +++------------- .../live/rec-play/test-got-playback-frames.py | 20 ++++++++----------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/media/playback/playback_device.cpp b/src/media/playback/playback_device.cpp index beab1a74b4..0a63f73f38 100644 --- a/src/media/playback/playback_device.cpp +++ b/src/media/playback/playback_device.cpp @@ -151,7 +151,6 @@ rs2_extrinsics playback_device::calc_extrinsic(const rs2_extrinsics& from, const playback_device::~playback_device() { - (*m_read_thread)->invoke([this](dispatcher::cancellable_timer c) { std::lock_guard locker(_active_sensors_mutex); for (auto&& sensor : m_active_sensors) @@ -161,12 +160,6 @@ playback_device::~playback_device() sensor.second->stop(); } } - }); - - if((*m_read_thread)->flush() == false) - { - LOG_ERROR("Error - timeout waiting for flush, possible deadlock detected"); - assert(0); //Detect this immediately in debug } (*m_read_thread)->stop(); @@ -454,8 +447,8 @@ void playback_device::start() catch_up(); try_looping(); LOG_INFO("Playback started"); - } + void playback_device::stop() { LOG_DEBUG("playback stop called"); @@ -469,8 +462,8 @@ void playback_device::stop() LOG_ERROR("Error - timeout waiting for flush, possible deadlock detected"); assert(0); //Detect this immediately in debug } - LOG_INFO("Playback stoped"); + LOG_INFO("Playback stopped"); } void playback_device::stop_internal() @@ -482,10 +475,7 @@ void playback_device::stop_internal() m_is_started = false; m_is_paused = false; - for (auto sensor : m_sensors) - { - //sensor.second->flush_pending_frames(); - } + m_reader->reset(); m_prev_timestamp = std::chrono::nanoseconds(0); catch_up(); @@ -524,7 +514,6 @@ void playback_device::do_loop(T action) { if( psc ) { - psc->flush_pending_frames(); psc->stop( false ); } } diff --git a/unit-tests/live/rec-play/test-got-playback-frames.py b/unit-tests/live/rec-play/test-got-playback-frames.py index 9d7892b9fa..8b442f4930 100644 --- a/unit-tests/live/rec-play/test-got-playback-frames.py +++ b/unit-tests/live/rec-play/test-got-playback-frames.py @@ -183,16 +183,14 @@ def stop_sensor( sensor ): except Exception: test.unexpected_exception() finally: # we must remove all references to the file so we can use it again in the next test - if recorder: - recorder.pause() - recorder = None - if playback: - playback.pause() - playback = None stop_sensor( depth_sensor ) depth_sensor = None stop_sensor( color_sensor ) color_sensor = None + if recorder: + recorder = None + if playback: + playback = None test.finish() @@ -240,16 +238,14 @@ def stop_sensor( sensor ): except Exception: test.unexpected_exception() finally: # we must remove all references to the file so the temporary folder can be deleted - if recorder: - recorder.pause() - recorder = None - if playback: - playback.pause() - playback = None stop_sensor( depth_sensor ) depth_sensor = None stop_sensor( color_sensor ) color_sensor = None + if recorder: + recorder = None + if playback: + playback = None test.finish() From 3a72cb831df76789aad0b8858329af802e0f3f96 Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 28 Jun 2021 08:22:54 +0300 Subject: [PATCH 3/3] Update libci.py --- unit-tests/py/rspy/libci.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unit-tests/py/rspy/libci.py b/unit-tests/py/rspy/libci.py index 0342c7be2c..a4c124d03f 100644 --- a/unit-tests/py/rspy/libci.py +++ b/unit-tests/py/rspy/libci.py @@ -359,8 +359,9 @@ def command( self ): # -S : don't imply 'import site' on initialization # NOTE: exit() is defined in site.py and works only if the site module is imported! cmd += ['-S'] - # '-u' --> Force stdin, stdout and stderr to be totally unbuffered - # We saw that with stdout buffing, it a test would exit on an access violation, no log can be found since it was buffered. + # -u : force the stdout and stderr streams to be unbuffered; same as PYTHONUNBUFFERED=1 + # With buffering we may end up losing output in case of crashes! (in Python 3.7 the text layer of the + # streams is unbuffered, but we assume 3.6) cmd += ['-u'] if sys.flags.verbose: cmd += ["-v"]