Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix freeze in hdl_grabber.cpp #5826

Merged

Conversation

SunlayGGX
Copy link
Contributor

@SunlayGGX SunlayGGX commented Sep 28, 2023

Close the udp socket before stopping HDLGrabber. Fix only for Windows.
Linked to issue #4460

Close the udp socket before stopping HDLGrabber. Tested only on Windows.
@mvieth
Copy link
Member

mvieth commented Oct 16, 2023

@SunlayGGX Hi, thanks for this PR. It would be great if we could fix this for all systems, not only windows. I looked into the Boost documentation, which says that receive_from will complete with the boost::asio::error::operation_aborted error. So could this work:
if (e.code () != boost::asio::error::operation_aborted) ?

I am also wondering: shouldn't the part after the catch block (if (isAddressUnspecified ...) be inside the try block? If receive_from threw the exception, that part shouldn't be executed, right?

Unfortunately, I don't have a velodyne device for proper testing ...

@SunlayGGX
Copy link
Contributor Author

@mvieth Hi, thanks for reviewing my PR.

You're right about using boost error code, I'll change that. Though it's not boost::asio::error::operation_aborted but boost::asio::error::interrupted that is triggered, at least on Windows case.
I don't know if it will be right on Linux or MacOS and since I don't have those setup, I cannot test them, hence my Windows only fix.
Should I remove the ifdef and ignore boost::asio::error::interrupted and boost::asio::error::operation_aborted errors ?

For the second part of your review, let's do it like you proposed because the result is the same (enqueueHDLPacket is protected by a check if length is of the right size).

Finally, you don't need a Velodyne to test. As said in the issue #4460, before the fix : the freeze happens when you cannot connect to one (either it isn't seen on the network, or it doesn't exist) and try to close the grabber.
I'm confident the fix didn't change the behavior when the Velodyne successfully connects, it was tested on my side on Windows.

@mvieth
Copy link
Member

mvieth commented Oct 23, 2023

@SunlayGGX I tested with Ubuntu, no Velodyne device connected, and only calling hdl_read_socket_->close (); does not seem to be sufficient because the receive_from call is not interrupted. If I add hdl_read_socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both); before calling close () , like the Boost documentation suggests, then the receive_from call is interrupted, but shutdown throws an exception saying Transport endpoint is not connected. With the shutdown call, enclosed in a try-catch, it works on Ubuntu. If that works on Windows as well, we could add that before calling close()

Should I remove the ifdef and ignore boost::asio::error::interrupted and boost::asio::error::operation_aborted errors ?

Yes please, that sounds good

@SunlayGGX SunlayGGX force-pushed the fix-freeze-with-Velodyne-udp-stop branch from b50fc15 to 7f13704 Compare October 30, 2023 15:30
Address PR comments to fix HDLGrabber freeze on Windows and Linux.
@SunlayGGX SunlayGGX force-pushed the fix-freeze-with-Velodyne-udp-stop branch from 7f13704 to 8835fff Compare October 30, 2023 15:31
Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

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

Thank you, now the freeze is fixed on Linux, too 👍

@mvieth mvieth added the changelog: fix Meta-information for changelog generation label Nov 3, 2023
@SunlayGGX
Copy link
Contributor Author

Thank you so much for your review @mvieth .
I'll leave the merge of that PR to you if you're authorized, or anybody that could do it whenever they want.

@mvieth mvieth requested a review from larshg November 14, 2023 09:14
@mvieth
Copy link
Member

mvieth commented Nov 14, 2023

Thank you so much for your review @mvieth . I'll leave the merge of that PR to you if you're authorized, or anybody that could do it whenever they want.

I wanted to give @larshg the opportunity to take a look before I merge it 🙂

@larshg
Copy link
Contributor

larshg commented Nov 14, 2023

Sorry about the delay 😄

@larshg larshg merged commit a2e6f54 into PointCloudLibrary:master Nov 14, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Meta-information for changelog generation module: io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants