Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access violation writing 0x0000000000000000 on Windows 7 #59

Closed
andfoy opened this issue Oct 5, 2017 · 45 comments
Closed

Access violation writing 0x0000000000000000 on Windows 7 #59

andfoy opened this issue Oct 5, 2017 · 45 comments
Assignees
Milestone

Comments

@andfoy
Copy link
Owner

andfoy commented Oct 5, 2017

@jxrossel commented on Wed Oct 04 2017

Description of your problem

When starting spyder, I get an error message with "Terminal server could not be located (...)" and something about starting spyder in debugging mode (which I don't know how to do).

What steps will reproduce the problem?

  1. starting spyder

What is the expected output? What do you see instead?
error message and no terminal in the consoles

Please provide any additional information below

Versions and main components

  • Terminal Version: 0.2.2
  • Spyder Version: 3.2.3
  • Python Version: python-3.6.2.amd64 (from WinPython, then I just updated spyder and spyder-terminal)
  • Operating system: Windows 7

pip list

adodbapi (2.6.0.7) alabaster (0.7.10) algopy (0.5.5) altair (1.2.0) altair-widgets (0.1.2) argh (0.26.2) asgi-redis (1.4.3) asgiref (1.1.2) astroid (1.5.3) astroML (0.3) attrs (17.2.0) autobahn (17.9.3) Automat (0.6.0) Babel (2.4.0) backports-abc (0.5) backports.weakref (1.0rc1) baresql (0.7.4) bcolz (1.1.2) beautifulsoup4 (4.6.0) bkcharts (0.2) blaze (0.10.1) bleach (2.0.0) blosc (1.5.1) bloscpack (0.11.0) bokeh (0.12.9) boto3 (1.4.1) botocore (1.4.36) Bottleneck (1.2.1) bqplot (0.9.0) brewer2mpl (1.4.1) Brotli (0.6.0) certifi (2017.7.27.1) cffi (1.10.0) channels (1.1.8) chardet (3.0.4) circus (0.14.0) click (6.7) cloudpickle (0.3.1) clrmagic (0.0.1a2) colorama (0.3.9) colorcet (0.9.1) coloredlogs (7.3) comtypes (1.1.3) constantly (15.1.0) CVXcanon (0.1.1) cvxopt (1.1.9) cvxpy (0.4.10) cx-Freeze (5.0.2) cycler (0.10.0) cyordereddict (1.0.0) Cython (0.26) cytoolz (0.8.2) daphne (1.3.0) dask (0.15.1) datashader (0.5.0) datashape (0.5.2) db.py (0.5.3) decorator (4.1.2) dill (0.2.7.1) distributed (1.18.0) Django (1.11.5) django-debug-toolbar (1.7) django-modeltranslation (0.12.1) django-redis (4.8.0) django-spaghetti-and-meatballs (0.2.2) django-su (0.5.2) docopt (0.6.2) docrepr (0.1.0) docutils (0.14) ecos (2.0.4) edward (1.3.3) emcee (2.2.1) entrypoints (0.2.3) enum34 (1.1.6) fast-histogram (0.2.1) fastcache (1.0.2) fasteners (0.14.1) fastparquet (0.1.1) feather-format (0.3.1) Flask (0.12.2) Flask-Cors (3.0.3) formlayout (1.1.0) fuzzywuzzy (0.15.0) geopy (1.11.0) gitdb2 (2.0.0) GitPython (2.1.3) gmpy2 (2.0.8) greenlet (0.4.12) guidata (1.7.6) guiqwt (3.0.3) h5py (2.7.0) HeapDict (1.0.0) holoviews (1.8.2) html5lib (1.0b10) humanfriendly (4.4.1) husl (4.0.3) hyperlink (17.3.1) idna (2.5) imageio (2.2.0) imagesize (0.7.1) incremental (17.5.0) iowait (0.2) ipykernel (4.6.1) ipyleaflet (0.3.0) ipympl (0.0.5) ipyparallel (6.0.2) ipython (6.1.0) ipython-genutils (0.2.0) ipython-sql (0.3.8) ipywidgets (6.0.0) isort (4.2.15) itsdangerous (0.24) jedi (0.10.2) Jinja2 (2.9.6) jmespath (0.9.3) joblib (0.11) jsonschema (2.6.0) julia (0.1.2) jupyter (1.0.0) jupyter-client (5.1.0) jupyter-console (5.1.0) jupyter-core (4.3.0) jupyter-sphinx (0.1.1) jupyterlab (0.26.5) jupyterlab-launcher (0.3.1) Keras (2.0.6) keras-vis (0.4.1) Lasagne (0.2.dev1) lazy-object-proxy (1.3.1) livereload (2.5.1) llvmlite (0.19.0) lmfit (0.9.7) locket (0.2.0) lxml (3.8.0) Markdown (2.6.8) MarkupSafe (1.0) matplotlib (2.0.2) mccabe (0.6.1) metakernel (0.20.4) mistune (0.7.4) mizani (0.3.2) mkl-service (1.1.2) monotonic (1.3) moviepy (0.2.3.2) mpl-scatter-density (0.2) mpld3 (0.3) mpldatacursor (0.6.2) mpmath (0.19) msgpack-python (0.4.8) multipledispatch (0.4.9) multiprocess (0.70.5) mypy (0.521) mysql-connector-python (2.0.4) nbconvert (5.2.1) nbconvert-reportlab (0.1) nbdime (0.3.0) nbformat (4.3.0) netCDF4 (1.2.9) networkx (1.11) nltk (3.2.4) notebook (5.1.0rc1) numba (0.34.0) numdifftools (0.9.20) numexpr (2.6.2) numpy (1.13.1+mkl) numpydoc (0.7.0) oct2py (4.0.6) octave-kernel (0.26.2) odo (0.5.0) olefile (0.44) palettable (3.0.0) pandas (0.20.3) pandas-datareader (0.5.0) pandocfilters (1.4.2) param (1.5.1) partd (0.3.8) pathtools (0.1.2) patsy (0.4.1) pdfrw (0.3) pep8 (1.7.0) pexpect (4.2.1) pg8000 (1.10.5) pickleshare (0.7.4) Pillow (4.2.1) pip (9.0.1) pkginfo (1.4.1) plotnine (0.2.1) ply (3.10) port-for (0.3.1) prettytable (0.7.2) prompt-toolkit (1.0.15) protobuf (3.3.0) psutil (5.2.2) ptpython (0.41) ptyprocess (0.5.2) PuLP (1.6.8) Pweave (0.30.0a1) py (1.4.34) pyarrow (0.5.0) PyAudio (0.2.11) pybars3 (0.9.3) pybind11 (2.1.1) pycodestyle (2.3.1) pycparser (2.17) pyflakes (1.6.0) pyflux (0.4.15) pygame (1.9.3) Pygments (2.2.0) pylint (1.7.2) pymc (2.3.6) pymc3 (3.1) PyMeta3 (0.5.1) pymongo (3.5.0) pyodbc (4.0.17) PyOpenGL (3.1.1) pypandoc (1.3.2) pyparsing (2.2.0) PyQt5 (5.9) pyqtgraph (0.10.0) pyreadline (2.0) pyserial (3.4) pystache (0.5.4) pytest (3.2.0) python-dateutil (2.6.1) python-hdf4 (0.9) python-Levenshtein (0.12.0) python-snappy (0.5.1) pythonnet (2.4.0.dev0) PythonQwt (0.5.5) pytz (2017.2) PyWavelets (0.5.2) pywin32 (221) pywinpty (0.2.1) pywinusb (0.4.2) PyYAML (3.12) pyzmq (16.0.2) QtAwesome (0.4.4) qtconsole (4.3.0) QtPy (1.3.0) redis (2.10.6) reportlab (3.4.0) requests (2.18.3) requests-file (1.4.2) requests-ftp (0.3.1) requests-toolbelt (0.8.0) rope (0.10.5) rpy2 (2.8.6) Rx (1.5.9) s3fs (0.1.2) s3transfer (0.1.10) scikit-fuzzy (0.3.dev0) scikit-image (0.13.0) scikit-learn (0.18.2) scikit-neuralnetwork (0.7) scikit-optimize (0.3) scilab2py (0.6) scipy (0.19.1) scs (1.2.6) seaborn (0.8.0) setuptools (36.2.7) simplegeneric (0.8.1) simplejson (3.11.1) sip (4.19.3) six (1.10.0) smmap2 (2.0.3) snakeviz (0.4.1) snowballstemmer (1.2.1) sortedcontainers (1.5.7) sounddevice (0.3.8) Sphinx (1.6.3) sphinx-autobuild (0.7.1) sphinx-rtd-theme (0.2.4) sphinxcontrib-websupport (1.0.1) spyder (3.2.3) spyder-notebook (0.2.0.dev0) spyder-reports (0.1.1) spyder-terminal (0.2.2) SQLAlchemy (1.1.13) sqlite-bro (0.8.11) sqlparse (0.2.3) statsmodels (0.8.0) supersmoother (0.4) sympy (1.1.1) tables (3.4.2) tblib (1.3.2) tensorflow (1.2.1) testpath (0.3.1) Theano (0.9.0) thriftpy (0.3.9) toolz (0.8.2) tornado (4.5.1) tqdm (4.15.0) traitlets (4.3.2) traittypes (0.0.6) tri.declarative (0.34.0) tri.form (5.0.1) tri.named-struct (0.12.0) tri.query (4.0.0) tri.struct (2.5.4) tri.table (5.0.0) twine (1.9.1) Twisted (17.9.0) twitter (1.17.1) txaio (2.8.2) typed-ast (1.0.4) urllib3 (1.21.1) vega (0.5.0) ViTables (3.0.0) watchdog (0.8.3) wcwidth (0.1.7) webencodings (0.5.1) Werkzeug (0.12.2) wheel (0.29.0) whitenoise (3.3.1) widgetsnbextension (2.0.0) winpython (1.9.20170812) wordcloud (1.3.2) wrapt (1.10.10) xarray (0.9.6) xlrd (1.0.0) XlsxWriter (0.9.8) xlwings (0.11.4) zarr (2.1.4) zict (0.1.2) zope.interface (4.4.3)

@andfoy commented on Wed Oct 04 2017

Hi @jxrossel, to start Spyder on debugging mode you must need to set the SPYDER_DEV variable, as it follows, the following commands must be executed from a system terminal, which corresponds to cmd.exe on Windows:

set SPYDER_DEV=True
spyder

After the execution, the file spyder_terminal_err.log must appear on your current working directory, which is this case must be the directory of the current terminal. Please post the contents of this file, so we can help you to trace the error.


@jxrossel commented on Thu Oct 05 2017

Hi, when starting spyder like that, I first had another error message "The Jupyter Notebook server failed to start..." and then the same message as above. The error log doesn't seem very helpful:

2017-10-05 10:15:14 ETACH-W113024 __main__[8060] INFO Server is now at: 127.0.0.1:8071
2017-10-05 10:15:14 ETACH-W113024 __main__[8060] INFO Shell: C:\Windows\system32\cmd.exe

I then tried to open a new terminal in spyder, and the error log became:

2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /?path=C:/Users/rosselj/PythonDev/satemo (127.0.0.1) 4.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/css/ubuntu.css (127.0.0.1) 133.95ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/xterm.css (127.0.0.1) 6.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/addons/fullscreen/fullscreen.css (127.0.0.1) 2.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/css/style.css (127.0.0.1) 3.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/promise-polyfill/promise.js (127.0.0.1) 6.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/fetch/fetch.js (127.0.0.1) 6.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/addons/attach/attach.js (127.0.0.1) 5.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/addons/fit/fit.js (127.0.0.1) 5.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/addons/fullscreen/fullscreen.js (127.0.0.1) 4.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/jquery/dist/jquery.min.js (127.0.0.1) 13.99ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/js/main.js (127.0.0.1) 5.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/components/xterm.js/dist/xterm.js (127.0.0.1) 48.98ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/css/fonts/ubuntumono-regular-webfont.woff2 (127.0.0.1) 5.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 GET /static/css/fonts/ubuntumono-bold-webfont.woff2 (127.0.0.1) 4.00ms
2017-10-05 10:18:05 ETACH-W113024 __main__[8060] INFO CWD: C:/Users/rosselj/PythonDev/satemo
2017-10-05 10:18:05 ETACH-W113024 __main__[8060] INFO Size: (56, 33)
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 POST /api/terminals?cols=56&rows=33 (127.0.0.1) 105.96ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] WARNING 404 GET /favicon.ico (127.0.0.1) 26.99ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 101 GET /terminals/0f5853 (127.0.0.1) 0.00ms
2017-10-05 10:18:05 ETACH-W113024 __main__[8060] INFO WebSocket opened: 0f5853
2017-10-05 10:18:05 ETACH-W113024 __main__[8060] INFO TTY On!
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 POST /api/terminals/0f5853/size?cols=67&rows=31 (127.0.0.1) 4.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 POST /api/terminals/0f5853/size?cols=61&rows=31 (127.0.0.1) 3.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 POST /api/terminals/0f5853/size?cols=67&rows=31 (127.0.0.1) 3.00ms
2017-10-05 10:18:05 ETACH-W113024 tornado.access[8060] INFO 200 POST /api/terminals/0f5853/size?cols=61&rows=31 (127.0.0.1) 3.00ms

The prompt in the terminal doesn't respond though


@andfoy commented on Thu Oct 05 2017

@jxrossel, can you open a browser tab on the server URL, as shown on the log file? On this case, 127.0.0.1:8071? Does a terminal appears there?

Also, I invite you to open an issue on spyder-notebook if you have notebook-related issues.


@jxrossel commented on Thu Oct 05 2017

Thanks for the answer, but pywinpty v0.2.1 is the last available version on pypi and its the one I have, so I can't update it...

I've stopped doing blind upgrades (with -U) since it tends to break installations (typically when upgrading a package which depends on the upgrade of another compiled package whose compilation fails...). Usually, I do a 2-step upgrade (with -U --no-deps first, then a simple install)


@jxrossel commented on Thu Oct 05 2017

... and I've checked the 127.0.0.1:8071 in my browser after opening Spyder. Nothing is shown on that page, but the tab title "OS Web terminal" is displayed (better than nothing, I guess!)


@andfoy commented on Thu Oct 05 2017

@jxrossel Is there any message on the developer Web console?


@jxrossel commented on Thu Oct 05 2017

SCRIPT445: Object doesn't support this action
File: main.js, Line: 11, Column: 1
var promptEvent = new Event('promptReady'); 

@andfoy commented on Thu Oct 05 2017

@jxrossel Can you test if pywinpty is working as expected? Please post the output of the following commands (From a Python prompt):

from winpty import PTY

# Start a new winpty-agent process of size (cols, rows)
cols, rows = 80, 25
process = PTY(cols, rows)

# Spawn a new console process, e.g., CMD
process.spawn(r'C:\windows\system32\cmd.exe')

# Read console output (Unicode)
process.read()

@jxrossel commented on Thu Oct 05 2017

process.spawn(r'C:\windows\system32\cmd.exe') --> True

process.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\winpty\winpty_wrapper.py", line 55, in read
    None, None)
OSError: exception: access violation writing 0x0000000000000000

@andfoy commented on Thu Oct 05 2017

@jxrossel Finally an error! Let me check, it seems that this belongs to pywinpty rather than spyder-terminal. However, let me investigate more about it, this is the first instance of such issue.

@andfoy andfoy changed the title Terminal server could not be located Access violation writing 0x0000000000000000 Oct 5, 2017
@andfoy andfoy added this to the v0.2.2 milestone Oct 5, 2017
@andfoy
Copy link
Owner Author

andfoy commented Oct 5, 2017

Actually, it seems that Windows API functions should be declared explicitly: asweigart/pyperclip#25 (comment)

@jxrossel
Copy link

jxrossel commented Oct 6, 2017

Still doesn't work:

File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\winpty\winpty_wrapper.py", line 63, in read
   ReadFile(self.conout_pipe, data, length, None, None)

OSError: exception: access violation writing 0x0000000000000000

@jxrossel
Copy link

jxrossel commented Oct 6, 2017

... and another error appeared in spyder after trying to open/close a terminal:

File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\spyder_terminal\terminalplugin.py", line 317, in <lambda>
  term.terminal_closed.connect(lambda: self.close_term(term=term))
File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\spyder_terminal\terminalplugin.py", line 330, in close_term
  term.close()
AttributeError: 'NoneType' object has no attribute 'close'
Traceback (most recent call last):
File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\spyder_terminal\terminalplugin.py", line 317, in <lambda>
  term.terminal_closed.connect(lambda: self.close_term(term=term))
File "C:\PortableSoftware\WinPython3-6\python-3.6.2.amd64\lib\site-packages\spyder_terminal\terminalplugin.py", line 330, in close_term
  term.close()
AttributeError: 'NoneType' object has no attribute 'close'

@andfoy
Copy link
Owner Author

andfoy commented Oct 6, 2017

I think this is an issue related to your distribution header files, I don't know what else to do on your case.

@jxrossel
Copy link

jxrossel commented Oct 6, 2017

You mean it doesn't / won't work with WinPython as distribution ?

@andfoy
Copy link
Owner Author

andfoy commented Oct 6, 2017

@stonebig, we have a problem here, have you had more problems with Access Violation Errors?

@andfoy
Copy link
Owner Author

andfoy commented Oct 6, 2017

@jxrossel, I've just asked to the current mantainer of WinPython if he can give us some help.

@stonebig
Copy link

stonebig commented Oct 6, 2017

I didn't notice, but also I'm not on Windows7, and I always live in next "beta". will re-check before next beta.

Well, I can't create a second Terminal2, it freeze the Terminal1, but I don't have any problem in Terminal1.

@MRGiacalone
Copy link

Following Pyperclip issue https://github.com/asweigart/pyperclip/issues/25 landed on this one. My issue seems to be related to the Windows 10 clipboard

In my case I am using Passpie to copy a password to the clipboard.

Traceback (most recent call last):
  File "m:\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "m:\miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "M:\Miniconda3\Scripts\passpie.exe\__main__.py", line 9, in <module>
  File "m:\miniconda3\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "m:\miniconda3\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "m:\miniconda3\lib\site-packages\click\core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "m:\miniconda3\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "m:\miniconda3\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "m:\miniconda3\lib\site-packages\passpie\cli.py", line 46, in wrapper
    return func(*args, **kwargs)
  File "m:\miniconda3\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "m:\miniconda3\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "m:\miniconda3\lib\site-packages\passpie\cli.py", line 275, in copy
    clipboard.copy(decrypted, clear)
  File "m:\miniconda3\lib\site-packages\passpie\clipboard.py", line 99, in copy
    _copy_windows(text, clear)
  File "m:\miniconda3\lib\site-packages\passpie\clipboard.py", line 55, in _copy_windows
    ctypes.cdll.msvcrt.wcscpy(ctypes.c_wchar_p(pchData), text)
OSError: exception: access violation writing 0x0000000000000000

I am not using WinPython, but rather Anaconda (Miniconda) on Windows 10. Python version 3.6.2 64 bit.

Any clues as to why the OSError: occurs while trying to use the clipboard?

@andfoy
Copy link
Owner Author

andfoy commented Nov 14, 2017

According to this SO answer, this an error ocurring on some 64-bit Python Windows binaries. I'm closing this issue since I don't know how to address this. All our ctypes calls have been tested and have been found to be functional.

@andfoy andfoy closed this as completed Nov 14, 2017
@andfoy andfoy modified the milestones: v0.2.2, v0.3 Nov 18, 2017
@andfoy andfoy reopened this Nov 25, 2017
@andfoy andfoy removed this from the v0.3 milestone Nov 25, 2017
@andfoy andfoy closed this as completed Nov 25, 2017
@blink1073 blink1073 reopened this Jan 18, 2018
@blink1073
Copy link
Collaborator

It seems as if the issue has resurfaced: cf jupyterlab/jupyterlab#3647

@andfoy
Copy link
Owner Author

andfoy commented Jan 19, 2018

@blink1073 It seems the error is still present on some x64 Windows Python distributions. AFAIK, we cannot solve this on our own account.

@mingwandroid
Copy link

Why not try using http://repo.msys2.org/msys/x86_64/winpty-0.4.3-1-x86_64.pkg.tar.xz which is compiled with mingw-w64 like winpty is supposed to be compiled? What are you even using this stuff for though? Why not just spawn a thread with an event loop to communicate with Python?

@ccordoba12
Copy link
Contributor

Ray, two things:

  1. winpty can be compiled with visual studio and mingw.
  2. We're not trying to communicate with Python. Instead, we want to have a pseudo terminal to be able to embed cmd or PowerShell in an application.

@mingwandroid
Copy link

mingwandroid commented Feb 2, 2018

winpty cannot be compiled with Visual Studio, please read the upstream https://github.com/rprichard/winpty

I believe someone added support for using Visual Studio but the runtime is then not the expected one (VC6 runtime) and you get this error. Whether this can be fixed or not (outside of compiling it with the compilers that the author supports => which are present in the msys2 channel in the Anaconda Distribution anyway) I do not know.

Regardless of that, can you (or someone with this problem) try my suggestion?

edit: OK, I didn't spot this part:

Compiling winpty with MSVC currently requires MSVC 2013 or newer.

But I believe (given that this is a Cygwin-derived project), that the author is unlikely to use or test with MSVC and it's safer to stick to mingw-w64.

@ccordoba12 ccordoba12 changed the title Access violation writing 0x0000000000000000 Access violation writing 0x0000000000000000 on Windows 7 Feb 6, 2018
@blink1073
Copy link
Collaborator

Yeah, it looks like Windows 7 is the common thread. I don't have access to Windows 7 for testing. We could use sys.getwindowsversion().major in the spyder-terminal and the notebook repo, which would also disable JupyterLab.

@blink1073
Copy link
Collaborator

Alternatively, we could raise an ImportError in this library based on that condition, which would require no changes to notebook.

@ccordoba12
Copy link
Contributor

ccordoba12 commented Feb 6, 2018

Good idea! It's better to do it here to avoid other applications using pywinpty on Win 7, since it's known to generate this ugly error.

Could you take care of that @blink1073?

@ccordoba12 ccordoba12 added this to the v0.5.2 milestone Feb 6, 2018
@blink1073
Copy link
Collaborator

Yep, coming right up!

@ccordoba12
Copy link
Contributor

Nice! Thanks a lot!

@blink1073
Copy link
Collaborator

Can someone with Windows 7 please test the following?

from winpty import PTY
p = PTY(80,25)
p.spawn('C:\\windows\\system32\\cmd.exe')
p.close()
del p

@dhirschfeld
Copy link

I don't seem to be seeing this issue myself on Win7

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 6.2.1 -- An enhanced Interactive Python.

In [1]: import winpty

In [2]: winpty.__version__
Out[2]: '0.5'

In [3]: from winpty import PTY
   ...: p = PTY(80,25)
   ...: p.spawn('C:\\windows\\system32\\cmd.exe')
   ...: p.close()
   ...: del p

In [3]: 

In [4]: from winpty import PTY
   ...: 
   ...: # Start a new winpty-agent process of size (cols, rows)
   ...: cols, rows = 80, 25
   ...: process = PTY(cols, rows)
   ...: 
   ...: # Spawn a new console process, e.g., CMD
   ...: process.spawn(r'C:\windows\system32\cmd.exe')
   ...: 
   ...: # Read console output (Unicode)
   ...: process.read()
   ...: 
Out[4]: b''
λ [environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
6      1      7601   65536

image

@blink1073
Copy link
Collaborator

@dhirschfeld, does the high level code work for you on Win 7 as well?

from winpty import PtyProcess

proc = PtyProcess.spawn('python')
proc.write('print("hello, world!")\r\n')
proc.write('exit()\r\n')
while proc.isalive():
	print(proc.readline())

@dhirschfeld
Copy link

dhirschfeld commented Feb 7, 2018

On the first attempt I got an OSError:

>>> proc = PtyProcess.spawn('python')
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

I tried again and got the access violation:

>>> proc = PtyProcess.spawn('python')
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Miniconda3\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Miniconda3\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Miniconda3\lib\site-packages\winpty\ptyprocess.py", line 331, in _read_in_thread
    data = pty.read(4096)
  File "C:\Miniconda3\lib\site-packages\winpty\winpty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

...and I'm now continuing to get the access violation with that code

@andfoy
Copy link
Owner Author

andfoy commented Feb 7, 2018

@blink1073 Do we have any idea of why the low-level API is working but not the high-level? Is very counterintuitive, as the reading access is done on the low-level side. But the example given by @dhirschfeld shows that the low level access is working as expected.

Sidenote: BTW, the 32-bit wheels up to the 4.2.0 release were compiled on Windows 7 without any problems.

@andfoy
Copy link
Owner Author

andfoy commented Feb 7, 2018

@dhirschfeld After trying the high-level access, does the low-level API works for you?

@dhirschfeld
Copy link

Yep, seems to.
Output from Python session:

>>> from winpty import PTY
>>> p = PTY(80,25)
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> p.close()
>>> del p
>>>
>>> from winpty import PtyProcess
>>> proc = PtyProcess.spawn('python')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\lib\site-packages\winpty\ptyprocess.py", line 114, in spawn
    inst = cls(proc)
  File "C:\Miniconda3\lib\site-packages\winpty\ptyprocess.py", line 49, in __init__
    self._server.bind(address)
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
>>>
>>>
>>> proc = PtyProcess.spawn('python')
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Miniconda3\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Miniconda3\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Miniconda3\lib\site-packages\winpty\ptyprocess.py", line 331, in _read_in_thread
    data = pty.read(4096)
  File "C:\Miniconda3\lib\site-packages\winpty\winpty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

>>>
>>>
>>> p = PTY(80,25)
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> p.close()
>>> del p

@blink1073
Copy link
Collaborator

Ah, my mistake. The low level code I posted doesn't attempt to read. It should be:

from winpty import PTY 
p = PTY(80,25) 
p.spawn('C:\\windows\\system32\\cmd.exe') 
p.read()
p.close() 
del p

@jjhelmus
Copy link

jjhelmus commented Feb 7, 2018

Here are the results from a Windows 7 VM using the packages from conda-forge

Python 3.6.4 | packaged by conda-forge | (default, Dec 24 2017, 10:11:43) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from winpty import PTY
>>> p = PTY(80,25)
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> p.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\builder\Anaconda3\envs\test_winpty\lib\site-packages\winpty\win
pty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000
Python 3.6.4 | packaged by conda-forge | (default, Dec 24 2017, 10:11:43) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from winpty import PtyProcess
>>> proc = PtyProcess.spawn('python')
>>> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\builder\Anaconda3\envs\test_winpty\lib\threading.py", line 916,
 in _bootstrap_inner
    self.run()
  File "C:\Users\builder\Anaconda3\envs\test_winpty\lib\threading.py", line 864,
 in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\builder\Anaconda3\envs\test_winpty\lib\site-packages\winpty\pty
process.py", line 331, in _read_in_thread
    data = pty.read(4096)
  File "C:\Users\builder\Anaconda3\envs\test_winpty\lib\site-packages\winpty\win
pty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

The same results are seen with the packages from the defaults channel.

@dalito
Copy link
Contributor

dalito commented Feb 7, 2018

On Windows7 Pro 64bit, SP1:

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import winpty
>>> winpty.__version__
'0.5.1'
>>> from winpty import PTY
>>> p = PTY(80,25)
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> p.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\dev_src\_pyve\stable_py36\lib\site-packages\winpty\winpty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000
>>> p.close()
>>> del p

@blink1073
Copy link
Collaborator

And how about this? We'd raise an import error if not valid:

from winpty import PTY 
p = PTY(80,25) 
valid = False
p.spawn('C:\\windows\\system32\\cmd.exe') 
try:
    p.read()
    valid = True
except OSError:
    pass
p.close() 
del p
print('valid?', valid)

@dalito
Copy link
Contributor

dalito commented Feb 7, 2018

>>> from winpty import PTY
>>> p = PTY(80,25)
>>> valid = False
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> try:
...     p.read()
...     valid = True
... except OSError:
...     pass
... p.close()
  File "<stdin>", line 6
    p.close()
    ^
SyntaxError: invalid syntax
>>> del p
>>> print('valid?', valid)
valid? False

@dhirschfeld
Copy link

Calling p.read() does give the access violation:

>>> from winpty import PTY
>>> p = PTY(80,25)
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> p.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\lib\site-packages\winpty\winpty_wrapper.py", line 73, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000
>>> p.read()
b''
>>> p.close()
>>> del p

The latter test results in valid=False for me:

>>> from winpty import PTY
>>> p = PTY(80,25)
>>> valid = False
>>> p.spawn('C:\\windows\\system32\\cmd.exe')
True
>>> try:
...     p.read()
...     valid = True
... except OSError:
...     pass
...
>>> p.close()
>>> del p
>>> print('valid?', valid)
valid? False

@nurp
Copy link

nurp commented Jun 7, 2018

I can't even import winpty on Windows7 with python 3.5.4.
I only wanted to run "jupyter notebook" but maybe this error is not a problem?

C:\Users\nurp\jupy>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from winpty import PTY
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python\Python35-32\lib\threading.py", line 914, in _bootstrap_inner
    self.run()
  File "C:\Python\Python35-32\lib\threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python\Python35-32\lib\site-packages\winpty\ptyprocess.py", line 331, in _read_in_thread
    data = pty.read(4096, blocking=True)
  File "C:\Python\Python35-32\lib\site-packages\winpty\winpty_wrapper.py", line 74, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x00000000

..........
same message replicated for 10 threads

C:\Users\nurp\jupy>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from winpty import PTY
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python\Python35-32\lib\threading.py", line 914, in _bootstrap_inner
    self.run()
  File "C:\Python\Python35-32\lib\threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python\Python35-32\lib\site-packages\winpty\ptyprocess.py", line 331, in _read_in_thread
    data = pty.read(4096, blocking=True)
  File "C:\Python\Python35-32\lib\site-packages\winpty\winpty_wrapper.py", line 74, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x00000000

@andfoy
Copy link
Owner Author

andfoy commented Jun 7, 2018

@nurp Thanks for the report, We've just merged a definitive solution for this issue on #108 and we expect to publish a hotfix release today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests