Skip to content

odb_foreach() issue #487

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

Closed
wants to merge 2 commits into from
Closed

odb_foreach() issue #487

wants to merge 2 commits into from

Conversation

yorah
Copy link
Contributor

@yorah yorah commented Aug 14, 2013

No description provided.

@jamill
Copy link
Member

jamill commented Aug 15, 2013

So, this is failing because:

  1. The natively allocated memory backing the git_oid is coming from a memory mapped region with the read only bit set.

  2. The default marshaling for git_oid => GitOid is to copy with the [InAttribute, OutAttribute]. So, the git_oid struct is copied to managed memory, and then the value is copied back to native memory when the method returns. It is this write back to native memory that is causing the crash here. If you include an [In] attribute on the ref GitOid id parameter for the git_odb_foreach_cb delegate definition, then the marshaller should not attempt to write the result back to native memory.

@nulltoken has indicated there might be issues with this approach in mono.

@@ -20,6 +20,16 @@ internal static unsafe class UnSafeNativeMethods
[DllImport(libgit2)]
internal static extern void git_strarray_free(ref git_strarray array);

internal delegate int git_odb_foreach_cb(
ref GitOid id,
Copy link
Member

Choose a reason for hiding this comment

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

@yorah As described by @jamill, could you please decorate this with a [In]?

This should make the test pass on Windows. However, I think it will still fail on Mono 2.10

@yorah
Copy link
Contributor Author

yorah commented Aug 19, 2013

Thanks @jamill , it indeed fixes the test on Windows.

The build still fails on Mono though.

@yorah
Copy link
Contributor Author

yorah commented Aug 19, 2013

Opened a bug on the Mono issue tracker.

@yorah
Copy link
Contributor Author

yorah commented Aug 21, 2013

/cc @joncham You've previously helped us with a Mono related bug. Did we mess up anyhow or does it look like a real issue to you?

@joncham
Copy link
Contributor

joncham commented Aug 21, 2013

I'll take a look at it.

@yorah
Copy link
Contributor Author

yorah commented Sep 9, 2013

The bug seems to be fixed on Mono side!

I guess we can close this issue since we found a workaround.

@yorah yorah closed this Sep 9, 2013
@nulltoken
Copy link
Member

Fixed in mono/mono@e682ece

@vargaz Thanks! ❤️

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.

4 participants