Skip to content

Conversation

johnhaley81
Copy link
Collaborator

Some properties were being set on the libgit2 C struct but would
be destroyed after the function is completed. The problem was that
C struct would still assume that the memory it had was valid and
would try to use it resulting in random segfaults.

Now you can mark an argument as saveArg and then that argument
will be persisted to the parent object and disposed of when the
parent is deleted.

Currently this only works in sync functions since I couldn't find
an async method that would need this. If this changes it shouldn't
be too hard to implement.

Another thing to note is that the if the parent object is marked
as !selfFreeing then we're still going to dispose of the
persisted objects because if not then they will memory leak all
over the place. This might need to be looked into more later. I
currently couldn't find a situation where this would happen but
the code is pretty complicated at this point and I certainly could
have missed something

Some properties were being set on the libgit2 C struct but would
be destroyed after the function is completed. The problem was that
C struct would still assume that the memory it had was valid and
would try to use it resulting in random segfaults.

Now you can mark an argument as `saveArg` and then that argument
will be persisted to the parent object and disposed of when the
parent is deleted.

Currently this only works in sync functions since I couldn't find
an async method that would need this. If this changes it shouldn't
be too hard to implement.

Another thing to note is that the if the parent object is marked
as `!selfFreeing` then we're still going to dispose of the
persisted objects because if not then they will memory leak all
over the place. This might need to be looked into more later. I
currently couldn't find a situation where this would happen but
the code is pretty complicated at this point and I certainly could
have missed something
@johnhaley81
Copy link
Collaborator Author

@tbranyen this should hopefully fix #419 and #416

@tbranyen
Copy link
Member

@johnhaley81 Oh snap, excellent find!

johnhaley81 added a commit that referenced this pull request Feb 24, 2015
Allow for saving of props to an object
@johnhaley81 johnhaley81 merged commit 396a039 into master Feb 24, 2015
@johnhaley81 johnhaley81 deleted the fix-saved-props branch February 24, 2015 17:15
@tbranyen tbranyen modified the milestone: 0.3.0 Mar 2, 2015
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