Skip to content

address bugprone-exception-escape warning from clang-tidy. - #1894

Closed
fujitatomoya wants to merge 1 commit into
ros2:masterfrom
fujitatomoya:20220228-bugprone-exception-escape
Closed

fujitatomoya wants to merge 1 commit into
ros2:masterfrom
fujitatomoya:20220228-bugprone-exception-escape

Conversation

@fujitatomoya

Copy link
Copy Markdown
Collaborator

draft for #1890

Signed-off-by: Tomoya Fujita Tomoya.Fujita@sony.com

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

@ivanpauno ivanpauno left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Did you verify this solves #1890?

@fujitatomoya

Copy link
Copy Markdown
Collaborator Author

@ivanpauno no, im not sure how to do that... @alsora could i have some help here? or could you tell me how to verify?

RCLCPP_DEBUG(logger, "Load library %s", library_name.c_str());
auto loader = new class_loader::ClassLoader(library_name);
try {
auto loader = new class_loader::ClassLoader(library_name);

@alsora alsora Mar 7, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code does not compile.
you should have
class_loader::ClassLoader * loader = nullptr;
outside of the try catch otherwise you will can't access it later

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly unrelated, but is there a reason why we use a raw pointer here?
this is not even deallocated at the end of the file (not a big deal, but still bad to see).

@alsora alsora left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does not compile as it is.
However, with a minimal change (described above) it does and the try catch block fixes the bugprone warning.

@alsora

alsora commented Mar 7, 2022

Copy link
Copy Markdown
Collaborator

Sorry, I made a mistake. The error is still there even after your patch.
It looks like this is the function throwing an exception https://github.com/ros/class_loader/blob/galactic/include/class_loader/class_loader_core.hpp#L316

@alsora

alsora commented Mar 7, 2022 •

Copy link
Copy Markdown
Collaborator

@fujitatomoya I stole your try-catch block and I opened a PR that fixes the issue: #1895

@fujitatomoya

Copy link
Copy Markdown
Collaborator Author

@alsora thanks! i will review #1895 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants