[issue36736] Python crashes when calling win32file.LockFileEx

2019-04-27 Thread Eryk Sun


Eryk Sun  added the comment:

> win32file.LockFileEx(h, win32con.LOCKFILE_EXCLUSIVE_LOCK, 5, 5, None)

This is a third-party issue in the PyWin32 package. win32file.LockFileEx 
shouldn't allow passing None for the required 5th parameter `ol` (i.e. the 
lpOverlapped parameter of WINAPI LockFileEx [1]). Or at least it should 
allocate a default overlapped record in this case, with the offset set to 0. 
Passing a NULL pointer leads to an access-violation exception.

[1]: 
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-lockfileex

FYI, setting a lock on the file is unecessary in this case. You created the 
kernel file object without data-access sharing (i.e. shareMode == 0). Until the 
handle is closed, opening the file again with read or write data access will 
fail as a sharing violation (32).

--
nosy: +eryksun
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36736] Python crashes when calling win32file.LockFileEx

2019-04-27 Thread Anand Arumugam


New submission from Anand Arumugam :

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32file
>>> import win32con
>>> import platform
>>> h = win32file.CreateFile(f'd:\\temp\\{platform.node()}.lock', 
>>> (win32file.GENERIC_READ | win32file.GENERIC_WRITE), 0, None, 
>>> win32con.CREATE_NEW, 0, None)
>>> win32file.LockFileEx(h, win32con.LOCKFILE_EXCLUSIVE_LOCK, 5, 5, None)

The moment I hit enter, python command prompt crashes. I'm unable to attach the 
crash dump file. If you cannot repro the crash, let me know.

--
assignee: terry.reedy
components: IDLE, Windows
messages: 340947
nosy: paul.moore, steve.dower, terry.reedy, tim.golden, yapydev, zach.ware
priority: normal
severity: normal
status: open
title: Python crashes when calling win32file.LockFileEx
type: crash
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com