[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2018-07-10 Thread Eryk Sun


Eryk Sun  added the comment:

> I don't understand why Python behaves differently in debug mode.
> For me, if Python is able to trigger an exception on EINVAL, we 
> should also get a regular Python exception in debug mode (and not 
> a crash)

The debug build's behavior isn't related to the invalid parameter handler, and 
it's not necessarily a crash. The default report mode for CRT_ERROR and 
CRT_ASSERT is CRTDBG_MODE_WNDW. This pops up a dialog asking whether to abort 
the process, ignore the error (fail and set errno), or retry if a debugger is 
attached (i.e. break into the debugger with a first-chance exception).

The mode can be changed to CRTDBG_MODE_DEBUG, which writes a message to the 
debugger, if one is attached to the process:

msvcrt.CrtSetReportMode(msvcrt.CRT_ASSERT, msvcrt.CRTDBG_MODE_DEBUG)

For example, in this case a message is written about the failed assertion in 
exec\spawv.cpp on line 276 (in this case the debugger is cdb, sharing the same 
console as Python, so the failed assertion message is inlined with Python's 
traceback):

>>> os.spawnl(os.P_WAIT, '', 'non-empty')
minkernel\crts\ucrt\src\desktopcrt\exec\spawnv.cpp(276) : Assertion failed: 
file_name[0] != '\0'
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python37\lib\os.py", line 931, in spawnl
return spawnv(mode, file, args)
OSError: [Errno 22] Invalid argument

or set the report mode to CRTDBG_MODE_FILE with the file set to 
CRTDBG_FILE_STDERR:

msvcrt.CrtSetReportMode(msvcrt.CRT_ASSERT, msvcrt.CRTDBG_MODE_FILE)
msvcrt.CrtSetReportFile(msvcrt.CRT_ASSERT, msvcrt.CRTDBG_FILE_STDERR)

--

___
Python tracker 

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



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2018-07-10 Thread STINNER Victor


STINNER Victor  added the comment:

> Crashing happens only with the debug build.

I don't understand why Python behaves differently in debug mode. For me, if 
Python is able to trigger an exception on EINVAL, we should also get a regular 
Python exception in debug mode (and not a crash).

--

___
Python tracker 

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



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2018-07-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Crashing happens only with the debug build. With the release mode I got 
OSError(EINVAL). I think it is better to raise the same error in all builds. 
ValueError is not new, it is already raised for paths containing NUL and too 
long paths.

--

___
Python tracker 

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



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2018-07-10 Thread Eryk Sun


Eryk Sun  added the comment:

Serhiy, an empty file path shouldn't crash the interpreter. The per-thread 
invalid parameter handler is suppressed before calling _wspawnv, so it should 
raise OSError (EINVAL) if the file path is empty. That's what I observe in 3.7. 
Are you suggesting to raise ValueError in this case instead of calling _wspawnv?

--
nosy: +eryksun

___
Python tracker 

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



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2018-07-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

All three test cases are raising a VallueError now:

C:\py\cpython3.8>python -c "import os; os.spawnl(os.P_WAIT, '')"
Running Debug|x64 interpreter...
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\py\cpython3.8\\lib\os.py", line 931, in spawnl
return spawnv(mode, file, args)
ValueError: spawnv() arg 2 cannot be empty

C:\py\cpython3.8>python -c "import os; os.spawnl(os.P_WAIT, 
'__not_existing_path__')"
Running Debug|x64 interpreter...
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\py\cpython3.8\\lib\os.py", line 931, in spawnl
return spawnv(mode, file, args)
ValueError: spawnv() arg 2 cannot be empty

C:\py\cpython3.8>python -c "import os; os.spawnl(os.P_WAIT, 
'__not_existing_path__', '')"
Running Debug|x64 interpreter...
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\py\cpython3.8\\lib\os.py", line 931, in spawnl
return spawnv(mode, file, args)
ValueError: spawnv() arg 2 first element cannot be empty


But the following one still causes a crash:

  python -c "import os; os.spawnl(os.P_WAIT, '', 'non-empty')"

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-10-26 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

added some tests (not sure if in appropriate place).

--
Added file: http://bugs.python.org/file23529/issue_8036_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-10-25 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

against py3k branch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-10-25 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Now we are using Mercurial, and what was called 'py3k' on SVN is now 'default'. 
 Since we now commit on older branches first and then merge with the most 
recent ones, the patch should either be against 3.2 or 2.7.
You can check the devguide for more informations.

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-10-24 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-10-24 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

@nvetoshkin: Can you please also write tests (in Lib/test/test_os.py) for your 
patch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-06-12 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.3 -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-03-11 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

Attached first attempt to close this issue. Are there enough checks? It passes:
os.spawnl(os.P_WAIT, '')
os.spawnl(os.P_WAIT, 'path')
os.spawnl(os.P_WAIT, 'path', '')

--
keywords: +patch
nosy: +nvetoshkin
Added file: http://bugs.python.org/file21080/issue8036_0.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-02-24 Thread Ralf Schmitt

Changes by Ralf Schmitt sch...@gmail.com:


--
nosy: +schmir

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-01-26 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

Should this just be resolved as a won't fix?

--
nosy: +dstanek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-01-26 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

No, the issue can be fixed by better checking the arguments.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2010-03-09 Thread Jean-Paul Calderone

Jean-Paul Calderone exar...@divmod.com added the comment:

Why is the Microsoft CRT argument error handler no longer disabled?

--
nosy: +exarkun

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2010-03-09 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

2.6 and 3.0.1 used to disable the Microsoft CRT argument error handler: they 
return EINVAL, but newer versions don't, and should check their arguments 
before calling _spawnv.

FWIW, the checks are::
pathname != NULL
*pathname != '\0'
argv != NULL
*argv != NULL
**argv != '\0'
The first and third checks are guaranteed by the implementation, but the other 
three should be done in posix_spawnv().
And the other calls to the various nt.spawn* functions probably suffer the same 
problem.

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2010-03-09 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Because this is a global setting for the whole process. This was discussed with 
issue4804.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2010-03-08 Thread Gabriel Genellina

Gabriel Genellina gagsl-...@yahoo.com.ar added the comment:

In case it matters, 3.0.1 does NOT crash.

--
nosy: +gagenellina

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8036
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com