Issue #42 resolved
Ronald Oussoren
repo owner created an issue

Review the C code in pyobjc-core for the GIL state: I just had a hang in the testsuite that seemed to be caused by code that tries to get the GIL while still owning it.

That code looked correct, but it likely has called code that doesn't do GIL handling correctly.

Comments (3)

  1. Ronald Oussoren reporter

    This method in OC_PythonUnicode:

            int is_exact_unicode;
                    is_exact_unicode = PyUnicode_CheckExact(value);
            if (is_exact_unicode) {
                    [super encodeWithCoder:coder];
            } else {
                    if ([coder allowsKeyedCoding]) {
                            [coder encodeInt32:2 forKey:@"pytype"];
                    } else {
                            int v = 2;
                            [coder encodeValueOfObjCType:@encode(int) at:&v];
                    PyObjC_encodeWithCoder(value, coder);

    When the whole method is in the block with PyObjC_BEGIN_WITH_GIL the test_archive_python tests hang when the libffi caller code tries to reaquire the GIL (and the most likely reason for this is that the GIL is already owned by the thread).

  2. Log in to comment