Python COM - limit on size/complexity of returned object?

Stefan Schukat SSchukat at dspace.de
Mon Jun 28 12:20:26 EDT 2004


There was a reference bug in pythoncom.dll which lead to such errors.
This should be fixed by now.

	Stefan


-----Original Message-----
From: pywin32-checkins-admin at lists.sourceforge.net
[mailto:pywin32-checkins-admin at lists.sourceforge.net]On Behalf Of Mark
Hammond
Sent: Saturday, May 01, 2004 1:31 AM
To: pywin32-checkins at lists.sourceforge.net
Subject: [pywin32-checkins] pywin32/com/win32com/src
oleargs.cpp,1.26,1.27


Update of /cvsroot/pywin32/pywin32/com/win32com/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15064

Modified Files:
	oleargs.cpp 
Log Message:
Fix a reference counting bug in the new arbitrary safearray code.  Large
arrays could cause a crash.


Index: oleargs.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** oleargs.cpp	25 Apr 2004 04:10:48 -0000	1.26
--- oleargs.cpp	1 May 2004 00:30:51 -0000	1.27
***************
*** 489,492 ****
--- 489,493 ----
  			// Retrieve the stored size in this dimension 
  			ppyobDimension = PyInt_FromLong(lDimension);
+ 			// Note: No ref added by PyDict_GetItem
  			ppyobDimensionSize =
PyDict_GetItem(ppyobDimensionDictionary, ppyobDimension);
  			if (NULL == ppyobDimensionSize) {
***************
*** 500,504 ****
  				{
  					// if not the same size => no new
dimension
- 					Py_XDECREF(ppyobDimensionSize);
  					Py_XDECREF(ppyobSize);
  					Py_XDECREF(ppyobDimension);
--- 501,504 ----
***************
*** 506,510 ****
  				}
  			}
- 			Py_XDECREF(ppyobDimensionSize);
  			Py_XDECREF(ppyobSize);
  			Py_XDECREF(ppyobDimension);
--- 506,509 ----





-----Original Message-----
From: python-list-bounces+sschukat=dspace.de at python.org
[mailto:python-list-bounces+sschukat=dspace.de at python.org]On Behalf Of
google at prodigycomputing.com
Sent: Saturday, June 26, 2004 11:22 AM
To: python-list at python.org
Subject: Re: Python COM - limit on size/complexity of returned object?


kveretennicov at yahoo.com (Konstantin Veretennicov) wrote in message
news:<5155aad2.0406250612.29d5039b at posting.google.com>...

> Well, I did some testing with python 2.3 (that's what I have).
> Not sure if it will cheer you up, but I had no problems.

Thanks for the pointer. I tried it on another machine with 2.3 and
that works with no problems.

And I made some further discoveries on the 2.2 side: the problem isn't
a limit on the size of the returned object, it's cumulative. I amended
GetProfileComponentMatrixEx() to return the first n rows of the
matrix, to find out what the limit was: like this
>>> print len(GetProfileComponentMatrixEx(10))
10
>>> print len(GetProfileComponentMatrixEx(40))
40
>>> print len(GetProfileComponentMatrixEx(80))
<GPF!>
But trying it repeatedly I found that I could only execute the
following line once: it crashed calling it with an argument of 40 the
second time:
>>> print len(GetProfileComponentMatrixEx(40))
40
>>> print len(GetProfileComponentMatrixEx(40))
<GPF!>
And then I tried this repeatedly:
>>> print len(GetProfileComponentMatrixEx(10))
and -- surprise! -- it failed about the 7th or 8th invocation.

So, now there are two possibilities. 
1. It's a 2.2 problem that is fixed in 2.3 (though I looked in
Sourceforge for the bug reports and this did not show up there).
2. It's a side-effect of the module I'm importing to do the actual
work. On the machine running 2.3, I had to write a stub to represent
this module, because it is a home machine that can't see the work
server where the data is.

If the DLL is at fault, I'm going to have a hard time convincing the
vendor that they have to fix it. If I were them, I'd be sceptical. The
DLL is loaded by the import statement, but in this test it is never
called. It's hard to see what it's initialization code could possibly
be doing to break pythoncom.
-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list