-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Segmentation fault at test_push_options()
#1301
Comments
I am looking at this code Line 112 in a9c7cce
which makes me believe that in this block Line 270 in a9c7cce
pushopts will be freed when the function is exited. Thus the test_push_options uses invalid memory.
|
For context push options were implemented in PR #1282 |
I am using Linux at x86_64, AMD hardware. |
Yeah, it looks like Like I said originally in #1282, I don't have any bright ideas for testing this because we basically want to peek into a structure that only lives ephemerally inside |
Alternatively, to keep some form of limited testing for push options, just the assertions for string contents can be removed: diff --git a/test/test_remote.py b/test/test_remote.py
index ee42535..dce094f 100644
--- a/test/test_remote.py
+++ b/test/test_remote.py
@@ -373,10 +373,7 @@ def test_push_options(mock_callbacks, origin, clone, remote):
remote.push(['refs/heads/master'], push_options=['foo'])
remote_push_options = mock_callbacks.return_value.push_options.remote_push_options
assert remote_push_options.count == 1
- assert ffi.string(remote_push_options.strings[0]) == b'foo'
remote.push(['refs/heads/master'], push_options=['Option A', 'Option B'])
remote_push_options = mock_callbacks.return_value.push_options.remote_push_options
assert remote_push_options.count == 2
- assert ffi.string(remote_push_options.strings[0]) == b'Option A'
- assert ffi.string(remote_push_options.strings[1]) == b'Option B' This is safe to do because the |
Cool, would you do a PR? |
Sure, see #1304. |
I am porting my company system to the latest libgit2/pygit2 and I stuck due to a test error, a memory violation to be specific.
It happens in test_push_options() at this exact line
assert ffi.string(remote_push_options.strings[0]) == b'foo'
I ran the test with a debugger and I see that
remote_push_options
looks fine,remote_push_options.strings
is a valid object, butremote_push_options.strings[0]
points to some garbage address like0x2d2d2d2d2d2d2d
. When ffi.string() tries to dereference the address it crashes.So I ran the test with address sanitizer and I got
heap-use-after-free
error, i.e. address pointing byremote_push_options.strings[0]
been freed somewhere else.Here are the address stanitizer stack traces, though they are for the C stack rather than for python code:
The text was updated successfully, but these errors were encountered: