Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Seg fault fix #11933
Seg fault fix #11933
Changes from 7 commits
3fbc443
d12edff
057808c
dcb07e4
4dd9761
8de38bf
7f130b3
ab64858
3dbabd0
f6572d8
c9446d8
e9ed70e
37043c9
d602afc
40c2824
06b15a1
adcdbed
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
setattr
necessary here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from what I know, how to set value for c-like structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An instance already has the attributes though:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is ct.memset(pschema, 0, ct.sizeof(schema))
by calling
schema = _SECRET_SCHEMA(name=_c_str("org.freedesktop.Secret.Generic"), flags=2, attributes=pattributes) only,
it is not guaranteed the rest of the memory is set to 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how that requires
setattr
. Wouldn't this still work?Also, why zero the schema's memory? You assign all its fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributes is an array which can be more than 2. In our case, we make 2 in the definition but no harm to set it. We only call it once so the cost is negligible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return is just a pointer, but the documentation says it should be freed with
secret_password_free
. I take that to implysecret_password_lookup_sync
may allocate memory internally which ctypes wouldn't free.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the gnome implementation. If we call secret_passwor_free, it complains invalid pointer. Given .net does not call it either (Azure/azure-sdk-for-net#10979) and it only calls once, I will keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an odd addition to, or repurposing of, this test. Do you mean to keep it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rename the test to test_segfault and want to use it as the seg fault regression test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I want to make sure calling into _get_refresh_token does not cause seg fault.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that's the intent of this line. What I mean is, the existing code uses a mock client to test whether the credential raises
CredentialUnavailableError
appropriately (I think the code is incorrect though). That's unrelated to whether the native interop causes a segfault, so testing both behaviors at once seems odd to me. But after taking a closer look at the existing code, I see it already calls_get_refresh_token
, so an explicit call here is redundant anyway.There's a larger problem with trying to catch this segfault with a test case though: when
libsecret-1.so.0
isn't available_get_refresh_token
returnsNone
without invoking any native code. When the test passes we can't say whether the code we meant to test works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libsecret-1.so.0 is installed in our test environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know that only because we've seen the segfault in CI runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We saw seg fault in CI which meant libsecret-1.so.0 was installed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it was installed on the agents that segfaulted. That doesn't mean it's installed on all agents, or always installed. If we don't know it's installed, we don't learn anything when the test passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. So I think this one + some manual testing should have a good coverage.