#26 restype uninitialized

closed-invalid
nobody
None
5
2006-03-15
2006-03-10
Martin v. Löwis
No

test_ctypes sporadically fails on OSX, e.g. in

http://www.python.org/dev/buildbot/trunk/g4%20osx.4%20trunk/builds/346/step-test/0

In this case, the following traceback is given

Traceback (most recent call last):
File
"/Users/buildslave/bb/trunk.4/build/Lib/ctypes/test/test_functions.py",
line 95, in test_intresult
self.failUnlessEqual(result, 21)
AssertionError: u'\x15' != 21

This is surprising, since apparently it decides to
create a Unicode character, instead of an integer.

On closer inspection, it seems that restype field of
CFuncPtrObject is never initialized (not even to NULL).
I think all fields should get some kind of initial value.

Discussion

  • Thomas Heller
    Thomas Heller
    2006-03-11

    Logged In: YES
    user_id=11105

    GenericCData_new calls the type's tp_alloc function, which,
    according to the docs, returns memory initialized to zero
    (except for certain fields). Isn't that understanding true?

    BTW: I have *never* seen such strange testresults before,
    although on OSX I didn't give the --with-pydebug flag to
    configure.

    Another question is: why does the buildbot show a green area
    for the test step although the test obviously failed?

     
  • Logged In: YES
    user_id=21627

    I see; the part with the initialization is fine, then. So it
    must be something else, e.g. memory corruption.

    As for the buildbot still displaying the test as passed: it
    uses the exit code from the make step to determine whether
    the tests passed or failed. Since the tests are run twice,
    and since only the second exit code counts, it considers the
    test passed if the second run passes. See
    Makefile.pre.in:testall.

     
  • Thomas Heller
    Thomas Heller
    2006-03-15

    Logged In: YES
    user_id=11105

    The test failures occurred when the test were run more than
    once. In this case the foreign function still has the
    restype assigend to it in the last test. I've fixed the test.

     
  • Thomas Heller
    Thomas Heller
    2006-03-15

    • status: open --> closed-invalid