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 filesystem iteration on Windows #469

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

clalancette
Copy link
Contributor

While looking through the logs of https://ci.ros2.org/view/nightly/job/nightly_win_deb/3114/ , I noticed that there was an "access violation". This didn't actually cause any tests to fail, but it is a bit weird so I decided to investigate.

What I found was that we were unnecessarily calling FindClose on Windows during rcutils_dir_iter_next when we failed to find another entry. Because we always call rcutils_dir_iter_close after use of the iterator, which also calls FindClose, we were running into UB on Windows. Fix that here by just removing the FindClose during rcutils_dir_iter_next.

While I was in here, I noticed that we were unnecessarily doing a bunch of casts from void pointers to the state pointers. But we can just use forward declaration for that, and remove the casts.

Instead of using a void pointer, use the forward-declared
pointer type.  While this won't make a difference for the
generated code, it will let us remove unnecessary casts.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
In particular, if we failed to find the next file on
Windows, we shouldn't necessarily close the handle; that's
the job of rcutils_dir_iter_end.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette
Copy link
Contributor Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette clalancette merged commit 8f5d6bc into rolling Jun 4, 2024
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the clalancette/fix-filesystem-iteration branch June 4, 2024 19:04
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.

2 participants