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 with string_at(None)
Type: crash Stage:
Components: ctypes Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, meador.inge, mwtoews, vstinner
Priority: normal Keywords:

Created on 2015-07-25 09:40 by mwtoews, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg247325 - (view) Author: Michael Toews (mwtoews) Date: 2015-07-25 09:40
On Debian x64 stable with Python 2.7 and 3.4, the following causes a segmentation fault:

from ctypes import string_at
string_at(None)

On Windows 64-bit with Python 2.7 it raises WindowsError and Python 3.3 raises OSError, both showing a message "access violation reading 0x0000000000000000", but it does not crash.

The above behavior was found when reading a result from a C API that can be either a zero-terminated string or NULL.
msg247327 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-07-25 09:49
ctypes gives you a raw access to the memory. If you try to read unmapped memory areas, the program may or may not crash. Usually, you get a segmentation fault.

https://en.wikipedia.org/wiki/Segmentation_fault

Python doesn't provide a portable behaviour on segmentation faults.

Note: You can use faulthandler to get the backtrace on segmentation fault.
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68902
2015-07-25 09:50:01vstinnersetstatus: open -> closed
2015-07-25 09:49:51vstinnersetresolution: not a bug

messages: + msg247327
nosy: + vstinner
2015-07-25 09:49:05serhiy.storchakasetnosy: + amaury.forgeotdarc, belopolsky, meador.inge

versions: + Python 3.5, Python 3.6, - Python 3.3
2015-07-25 09:40:48mwtoewscreate