Skip to content

Commit

Permalink
PR #12489 from Tamir91: Handle Coverity uncaught exception issues
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir authored Dec 18, 2023
2 parents 0470764 + b9c45f8 commit 509dbd9
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 30 deletions.
13 changes: 11 additions & 2 deletions src/callback-invocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ struct callback_invocation_holder

~callback_invocation_holder()
{
if( invocation )
owner->deallocate( invocation );
if( invocation && owner )
{
try
{
owner->deallocate( invocation );
}
catch( const std::exception & e )
{
LOG_DEBUG( "Error while callback holder deallocation: " << e.what() );
}
}
}

callback_invocation_holder & operator=( callback_invocation_holder && other )
Expand Down
13 changes: 10 additions & 3 deletions src/gl/align-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,15 @@ align_gl::align_gl(rs2_stream to_stream) : align(to_stream, "Align (GLSL)")

align_gl::~align_gl()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, []{});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}
13 changes: 10 additions & 3 deletions src/gl/colorizer-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,17 @@ namespace librealsense

colorizer::~colorizer()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, []{});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while performing cleaning up gpu resources" );
}
}

void colorizer::populate_floating_histogram(float* f, int* hist)
Expand Down
13 changes: 10 additions & 3 deletions src/gl/pointcloud-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,17 @@ void pointcloud_gl::create_gpu_resources()

pointcloud_gl::~pointcloud_gl()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, []{});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}

pointcloud_gl::pointcloud_gl()
Expand Down
13 changes: 10 additions & 3 deletions src/gl/synthetic-stream-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,16 @@ namespace librealsense
gpu_section::~gpu_section()
{
backup_content = false;
perform_gl_action([&](){
cleanup_gpu_resources();
}, []{});
try
{
perform_gl_action( [&]() {
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}

void gpu_section::create_gpu_resources()
Expand Down
13 changes: 10 additions & 3 deletions src/gl/upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ namespace librealsense

upload::~upload()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, [] {});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}

void upload::cleanup_gpu_resources()
Expand Down
13 changes: 10 additions & 3 deletions src/gl/y4112rgb-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@ y411_2rgb::y411_2rgb()

y411_2rgb::~y411_2rgb()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, []{});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}

rs2::frame y411_2rgb::process_frame(const rs2::frame_source& src, const rs2::frame& f)
Expand Down
13 changes: 10 additions & 3 deletions src/gl/yuy2rgb-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@ yuy2rgb::yuy2rgb()

yuy2rgb::~yuy2rgb()
{
perform_gl_action([&]()
try
{
cleanup_gpu_resources();
}, []{});
perform_gl_action( [&]()
{
cleanup_gpu_resources();
}, [] {} );
}
catch(...)
{
LOG_DEBUG( "Error while cleaning up gpu resources" );
}
}

rs2::frame yuy2rgb::process_frame(const rs2::frame_source& src, const rs2::frame& f)
Expand Down
9 changes: 8 additions & 1 deletion src/hw-monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ namespace librealsense

~locked_transfer()
{
_heap.wait_until_empty();
try
{
_heap.wait_until_empty();
}
catch(...)
{
LOG_DEBUG( "Error while waiting for an empty heap" );
}
}
private:
std::shared_ptr<platform::command_transfer> _command_transfer;
Expand Down
18 changes: 16 additions & 2 deletions src/linux/backend-hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ namespace librealsense

hid_input::~hid_input()
{
enable(false);
try
{
enable( false );
}
catch(...)
{
LOG_DEBUG( "Error while disabling a hid device" );
}
}

// enable scan input. doing so cause the input to be part of the data provided in the polling.
Expand Down Expand Up @@ -954,7 +961,14 @@ namespace librealsense
{
for (auto& elem : _streaming_iio_sensors)
{
elem->stop_capture();
try
{
elem->stop_capture();
}
catch(...)
{
LOG_DEBUG( "Error while stopping capture sensor" );
}
}

for (auto& elem : _streaming_custom_sensors)
Expand Down
9 changes: 8 additions & 1 deletion src/linux/backend-v4l2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ namespace librealsense

named_mutex::~named_mutex()
{
unlock();
try
{
unlock();
}
catch(...)
{
LOG_DEBUG( "Error while unlocking mutex" );
}
}

void named_mutex::lock()
Expand Down
10 changes: 8 additions & 2 deletions src/linux/udev-device-watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ udev_device_watcher::udev_device_watcher( const platform::backend * backend )

udev_device_watcher::~udev_device_watcher()
{
stop();

try
{
stop();
}
catch(...)
{
LOG_DEBUG( "Error while stopping udev device watcher" );
}
/* Release the udev monitor */
if( _udev_monitor )
udev_monitor_unref( _udev_monitor );
Expand Down
9 changes: 8 additions & 1 deletion src/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ namespace librealsense
LOG_WARNING(callbacks_inflight << " callbacks are still running on some other threads. Waiting until all callbacks return...");
}
// wait until user is done with all the stuff he chose to borrow
_callback_inflight.wait_until_empty();
try
{
_callback_inflight.wait_until_empty();
}
catch( const std::exception & e )
{
LOG_DEBUG( "Error while waiting for user callback to finish: " << e.what() );
}
}

identity_matcher::identity_matcher(stream_id stream, rs2_stream stream_type)
Expand Down

0 comments on commit 509dbd9

Please sign in to comment.