curl-and-python

Crash in test_write_to_file_via_object()

From: Gisle Vanem <gvanem_at_yahoo.no>
Date: Tue, 24 Dec 2013 00:30:56 +0100

I got the nose-tests to run. At least when I got the required packages to
install. Thank to easy_install. The crash now is at
'test_write_to_file_via_object (tests.write_to_file_test.WriteToFileTest)'

This is an iteration of the CRT-issue; Curl_client_write() calls fwrite()
on a file it didn't open with it's CRT (msvc100). But rather Python's CRT (msvcr90).

While WinDbg has suspended python, I see the tempfile
 f:\temp\tmpwaxbcv\pycurltest (0 bytes). It comes from the snippet:

    def test_write_to_file_via_object(self):
        self.curl.setopt(pycurl.URL, 'http://localhost:8380/success')
        dir = tempfile.mkdtemp()
        try:
            path = os.path.join(dir, 'pycurltest')
            f = open(path, 'wb+')
            try:
                self.curl.setopt(pycurl.WRITEDATA, f)
                self.curl.perform()

You cannot simply mix CRT's like this. If this works for you, it's pure luck.

Commenting out 'test_write_to_file_via_function()' and 'test_write_to_file_via_object()' in
write_to_file_test.py, no tests crashes. Although several results in ERROR.

FYI, here is some of the call-stack from WinDbg:

  ntdll!RtlpWaitForCriticalSection+0x8c
  ntdll!RtlEnterCriticalSection+0x46
  MSVCR100!_lock_file+0x3e
  MSVCR100!fwrite+0x44 << libcurl cannot write with this 'fp'. since
                                           fp = PyFile_AsFile(obj) is an MSVC90 object.

  libcurl!Curl_client_write(struct connectdata * conn = 0x00737365, int type = 0n0,
    char * ptr = 0x00000000 "", unsigned int len = 0)+0xc2 [g:\mingw32\src\inet\curl\lib\sendf.c @ 441]
  libcurl!readwrite_data(struct SessionHandle * data = <Memory access error>,
    struct connectdata * conn = 0x072ad7e8, struct SingleRequest * k = 0x082600a0,
    int * didwhat = <Memory access error>, bool * done = <Memory access error>)+0x631
   [g:\mingw32\src\inet\curl\lib\transfer.c @ 711]

--gv

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2013-12-24