This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: crash in winreg SetValueEx with memoryview
Type: crash Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.golden Nosy List: bdkearns, pitrou, python-dev, stutzbach, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2014-04-25 00:15 by bdkearns, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_winreg_setvalueex-py27.patch bdkearns, 2014-04-25 17:37
Messages (9)
msg217163 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-04-25 17:21
The new test fails with the patch applied:

======================================================================
ERROR: test_setvalueex_with_memoryview (__main__.LocalWinregTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "P:\ath\to\2.7\cpython\lib\test\test_winreg.py", line 336, in test_setvalueex_with_memoryview
    SetValueEx(ck, "test_name", None, REG_BINARY, memoryview('val'))
TypeError: Objects of type 'memoryview' can not be used as binary registry values

----------------------------------------------------------------------
msg217164 - (view) Author: Brian Kearns (bdkearns) * Date: 2014-04-25 17:37
Oops, updated test.
msg217181 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-04-26 01:57
Brian, it's not obvious (to me) what the original issue is ("crash"?) and why the new test expects a TypeError.
Also, is it a 2.7-only issue or does it also affect Python 3?
msg217182 - (view) Author: Brian Kearns (bdkearns) * Date: 2014-04-26 02:24
Are you aware of the old/new buffer interfaces and their usages? Did you actually try the code? "crash" would be obvious.

Objects that support only the new buffer interface define tp_as_buffer with fields representing the old buffer interface as null.

So, everywhere that uses the old buffer interface usually checks both tp_as_buffer != NULL and tp_as_buffer->bf_getreadbuffer != NULL. That second check is missing here before calling bf_getreadbuffer.
msg217186 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-04-26 08:42
I can confirm that the problem (which really is a hard crash) only applies to 2.7 and that the patch tests and fixes it. I'm happy to apply. Any objections?
msg217187 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-04-26 11:32
> Are you aware of the old/new buffer interfaces and their usages? Did
> you actually try the code? "crash" would be obvious.

I cannot try the code as I'm under Linux :-)
I was asking merely because many people report plain exception
tracebacks as "crashes". Yes, by reading the patch it came to me that it
was probably related to the coexistence of old and new buffer API, but I
prefer it to be confirmed by the reporter, rather than trust my own
intuition.

(I also wonder why the code did that manually instead of calling e.g.
PyObject_AsReadBuffer)
msg217200 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-26 14:49
New changeset 061db174baad by Tim Golden in branch '2.7':
Issue21349 Passing a memoryview to _winreg.SetValueEx now correctly raises a TypeError where it previously crashed the interpreter. Patch by Brian Kearns
http://hg.python.org/cpython/rev/061db174baad
msg217202 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-26 15:02
New changeset 9c38cfc7bed7 by Tim Golden in branch '2.7':
Add NEWS entry for issue21349
http://hg.python.org/cpython/rev/9c38cfc7bed7
msg217268 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-04-27 14:54
Committed. Thanks for the patch.
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65548
2014-04-27 14:54:10tim.goldensetstatus: open -> closed
resolution: fixed
messages: + msg217268

stage: resolved
2014-04-26 15:02:27python-devsetmessages: + msg217202
2014-04-26 14:49:00python-devsetnosy: + python-dev
messages: + msg217200
2014-04-26 11:32:42pitrousetmessages: + msg217187
2014-04-26 08:42:20tim.goldensetassignee: tim.golden

messages: + msg217186
nosy: + tim.golden
2014-04-26 02:24:10bdkearnssetmessages: + msg217182
2014-04-26 01:57:33pitrousetnosy: + pitrou, stutzbach
messages: + msg217181
2014-04-25 17:38:23bdkearnssetfiles: - fix_winreg_setvalueex-py27.patch
2014-04-25 17:38:00bdkearnssetfiles: + fix_winreg_setvalueex-py27.patch

messages: + msg217164
2014-04-25 17:21:22zach.waresetmessages: + msg217163
2014-04-25 12:22:06berker.peksagsetnosy: + zach.ware
2014-04-25 00:16:22bdkearnssetfiles: + fix_winreg_setvalueex-py27.patch
2014-04-25 00:16:12bdkearnssetfiles: - fix_winreg_setvalueex-py27.patch
2014-04-25 00:15:16bdkearnscreate