On 23May2017 1212, Victor Stinner wrote:
2017-05-22 13:17 GMT-05:00 Steve Dower <steve.do...@python.org>:
Once the special protection is removed, most of these cases will become
OSError due to the general protection against segmentation faults.

It didn't know that ctypes on Windows had a special protection against
programming errors. I'm not aware of such protection Linux. If you
call a function with the wrong number of arguments, it's likely to
crash or return random data.

I guess that the point is to help debugging. But since Python 3.6,
faulthandler now registers a Windows exception handler and so it able
to dump the Python traceback on any Windows exception:
https://docs.python.org/dev/library/faulthandler.html#faulthandler.enable

So I think that it's now fine to remove the ctypes protection. Just
advice (remind? ;-)) users to enable faulthandler: python3 -X
faulthandler, or call faulthandler.enable(). (You might want to use a
log file for that on Windows, depends on the use case.)

faulthandler is already recommended in the docs, and the existing SEH protection for access violations will remain (since that is independent of libffi).

I'll be honest, I have appreciated the functionality in the past, but it really isn't good practice and getting rid of it will be an overall benefit. Technically even the segfault protection isn't a great idea, since you really do end up in an unknown state with regards to memory page allocations, but it's better than crashing all the way out.

Cheers,
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to