Skip to content
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

ValueError: PyCapsule_SetPointer called with null pointer #6

Closed
Stolb27 opened this issue Jul 16, 2015 · 14 comments
Closed

ValueError: PyCapsule_SetPointer called with null pointer #6

Stolb27 opened this issue Jul 16, 2015 · 14 comments

Comments

@Stolb27
Copy link

Stolb27 commented Jul 16, 2015

on call kerberos.authGSSServerClean(context)

Cause:

if PY_MAJOR_VERSION >= 3

    PyCapsule_SetPointer(pystate, NULL);

else

in authGSSServerClean in kerberos.c

Documentation:
int PyCapsule_SetPointer(PyObject *capsule, void *pointer)
Set the void pointer inside capsule to pointer. The pointer may not be NULL.
https://docs.python.org/3.4/c-api/capsule.html#capsules

@02strich
Copy link
Owner

Thanks for raising this point. I have not found a nice and backwards compatible way to address this issue and welcome any ideas. Conceptually I would convert the clean functions to destructors of the pyCapsule state, but I am not sure this behaves the same.

Alternatively, one could remove the line and depend on the Python application not calling the clean function twice, which would be even worse.

@Stolb27
Copy link
Author

Stolb27 commented Jul 21, 2015

http://svn.python.org/projects/python/trunk/Objects/capsule.c
When the number of references to an python object becomes equal to zero, the function from pointer tp_dealloc is called. In the case of PyCapsule object, there is pointer to capsule_dealloc function.
static void capsule_dealloc(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
if (capsule->destructor) {
capsule->destructor(o);
}
PyObject_DEL(o);
}
Consequently, in the case of using PyCapsule, nothing to do. Right?

@laurivosandi
Copy link

Hi, facing the same issue here with Python3. Currently the only workaround is commenting out authGSSServerClean lines?

@Stolb27
Copy link
Author

Stolb27 commented Oct 26, 2015

Hi. I made the fork https://github.com/Stolb27/pykerberos, which, I think, has solved this problem. But I'm not sure I do the right thing, to offer pull-request. It might be not to remove clean-methods, leaving them empty and marking depricated. 02strich, this solution is suitable for pull-request?

@02strich
Copy link
Owner

I will have a look at it tonight. Just for my education, can you explain what exact kind of issue where you facing on Py3? Compiler issues?
On Oct 26, 2015, at 15:23, Lauri Võsandi <notifications@git.luolix.topmailto:notifications@github.com> wrote:

Hi. I made the fork https://github.com/Stolb27/pykerberos, which, I think, has solved this problem. But I'm not sure I do the right thing, to offer pull-request. It might be not to remove clean-methods, leaving them empty and marking depricated. 02strich, this solution is suitable for pull-request?


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-151301861.

@02strich
Copy link
Owner

@Stolb27 glancing over the code that looks very interesting. If you are ok with it, let's get a pull request going and see where we get to?

@laurivosandi
Copy link

Hi again, I get "PyCapsule_SetPointer called with null pointer" errors whenever I have authGSSServerClean in my code. Interestingly the exceptions are not raised by authGSSServerClean but by arbitrary statements in the code. I'm sure that authGSSServerClean is not being called twice and I am not referencing to the objects after calling authGSSServerClean.

@02strich
Copy link
Owner

02strich commented Nov 9, 2015

Hi,

I am sorry for taking so long to get back to this. @Stolb27 your changes are very interesting and I incorporated some of them into master here - can you have a look?

@laurivosandi can you try head of master, it should fix your issue?

@Stolb27
Copy link
Author

Stolb27 commented Nov 10, 2015

Omg...
Are you sure you want to call a method with the O-option in the format string of method Py_BuildValue? I think the reference count is not decremented to zero and the destructor will not work. You may need to use the N-option (according to https://docs.python.org/3/c-api/arg.html#building-values).
PS. There are a few warnings when building the library, I solved my request. Maybe these changes also accept?
PS2. Similarly, the file test.py is not compatible with py3.

@02strich
Copy link
Owner

Thanks for the hint with the N vs O, that is actually also broken upstream. Also fixed the warnings and the test.py. What other changes did you have in mind?

@Stolb27
Copy link
Author

Stolb27 commented Nov 10, 2015

Thank you. Everything is fine:)

Perhaps this is a separate issue, but ... In Debian 8 krb5-config has been renamed to krb5-config.mit (don't know, why).

(env) user@debian:~/development/kerberos-test/pykerberos$ python setup.py build
Traceback (most recent call last):
  File "setup.py", line 31, in check_krb5_config
    process = subprocess.Popen(("krb5-config",) + options, stdout=subprocess.PIPE, universal_newlines=True)
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'krb5-config'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 50, in <module>
    extra_link_args = check_krb5_config("--libs", "gssapi")
  File "setup.py", line 42, in check_krb5_config
    raise Exception("You are missing krb5-config")
Exception: You are missing krb5-config

Can you somehow solve?

@02strich
Copy link
Owner

Can you check whether the new master HEAD solves the debian problem?

@Stolb27
Copy link
Author

Stolb27 commented Dec 15, 2015

Yes, there is no more error. Thank you.

вт, 15 дек. 2015 г., 15:27, Stefan Richter notifications@github.com:

Can you check whether the new master HEAD solves the debian problem?


Reply to this email directly or view it on GitHub
#6 (comment).

С уважением, Василий Иванов

@02strich
Copy link
Owner

Thanks for your help. I have pushed the changes into v1.1.9 and uploaded the new version to PyPi

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

No branches or pull requests

3 participants