regression bug in pywintypes SECURITY_ATTRIBUTES? reference counting?
Dale Nagata
dnagata at creo.com
Wed Jan 22 00:47:09 EST 2003
I've migrated some code from Python 1.5.2 to 2.2.2 with win32all-148, most
works just fine.
One thing that I can't quite figure out is why code exactly like in
...\python\Lib\site-packages\win32\demos\service\pipeTestService.py
now gives me the following error when before it worked fine in 1.5.2:
pywintypes.error: (1336, 'CreateEvent', 'The access control list (ACL)
structure
is invalid.')
the code looks something like:
def MySecurityAttributes():
sa = pywintypes.SECURITY_ATTRIBUTES()
sidEveryone = pywintypes.SID()
sidEveryone.Initialize(SECURITY_WORLD_SID_AUTHORITY, 1)
sidEveryone.SetSubAuthority(0, SECURITY_WORLD_RID)
sidCreator = pywintypes.SID()
sidCreator.Initialize(SECURITY_CREATOR_SID_AUTHORITY, 1)
sidCreator.SetSubAuthority(0, SECURITY_CREATOR_OWNER_RID)
acl = pywintypes.ACL()
acl.AddAccessAllowedAce(GENERIC_READ|GENERIC_WRITE, sidEveryone)
acl.AddAccessAllowedAce(FILE_ALL_ACCESS, sidCreator)
sa.SetSecurityDescriptorDacl( True, acl, False ) # bDaclPresent ...
bDaclDefaulted
sa.bInheritHandle = False
return sa
def test():
sa = MySecurityAttributes()
hEvent = win32event.CreateEvent( sa, True, False, None ) # raises
win32api.error 1336???
If I move the code from the body of MySecurityAttributes() inline into
test(), then it works!
So that sounds to me like there's some kind of reference counting problem in
the C code.
I've checked out the code from CVS and rebuilt PyWinTypes23.dll with debug
and
set breakpoints, but as far as I can tell, all looks fine upon leaving
PySECURITY_ATTRIBUTES::SetSecurityDescriptorDacl,
so that suggests that some part of it gets garbage collected by the time
it reaches win32event.SetEvent, which I haven't yet started debugging.
Can anybody with more reference counting experience see where the
dangling pointer is happening?
thanks in advance,
--
Dale Nagata, Software Developer
Printing Workflow Solutions, Creo Inc. (Vancouver)
More information about the Python-list
mailing list