Skip to content

Tree walk: bugfix #352

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

Merged
merged 2 commits into from
Sep 12, 2018
Merged

Tree walk: bugfix #352

merged 2 commits into from
Sep 12, 2018

Conversation

asayers
Copy link
Contributor

@asayers asayers commented Sep 12, 2018

From https://github.com/alexcrichton/git2-rs/pull/343:

I'm seeing some strange behaviour with this feature. I have a callback which returns TreeWalkResult::Ok unconditionally, and I expect every node in the tree to be visited. Instead I see a subset of the top-level nodes only, and this subset is not deterministic across runs! Looks like something nasty is happening. Returning 0 from the callback instead gives the expected behaviour.

I haven't been able to observe this behaviour in this branch.

Currently if T is not 4 bytes long we get undefined behaviour.
As per the discussion in libgit2/libgit2#4703.
This requires making TreeWalkResult #[repr(i32)], which is fine.  Also,
remove an unnecessary pragma.
@alexcrichton alexcrichton merged commit 3d61c66 into rust-lang:master Sep 12, 2018
@alexcrichton
Copy link
Member

Thanks!

@asayers
Copy link
Contributor Author

asayers commented Sep 13, 2018

Tree::walk() should now be safe, but treewalk_cb is unsafe. However, I can't mark it as unsafe, because raw::git_tree_walk expects a safe function. Options:

  • Document the invariant and cross fingers.
  • Monomorphise tree::Walk and force the user to return TreeWalkResult.
  • Some way to mark treewalk_cb as unsafe that I'm not thinking of?

@alexcrichton
Copy link
Member

Ah that's ok, it's an internal function so it should be fine to leave as "safe", but adding documentation would also be great!

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