ionelmc / python-tblib

Serialization library for Exceptions and Tracebacks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"dump_traceback causes python3.4 to segfault on cygwin"

jamadden opened this issue · comments

gevent vendors a (lightly modified) version of tblib 1.0.0 (I believe). We've recently got a report that it seems to cause the Python 3.4 inteprpreter to segfault on Windows/Cygwin. Some amount of detail and reproduction instructions are in gevent/gevent#763 I've reviewed the release notes since then and don't see anything about that platform combo being fixed. Should we consider this a tblib bug that can be fixed, or an unsupported platform?

As a gevent maintainer I'll assist however I can (thank you for this library!), but I don't have access to cygwin. The original reporter, @rossengeorgiev , has indicated a willingness to help track down the cygwin specific issues too.

Sure, why not. Is there any reproducer that don't involve gevent?

Or a reproducer that uses just the vendored _tblib?

I'll have to leave it to @rossengeorgiev to say for sure, but I think the conclusion was that simply using dump_traceback on Cygwin Python 3.4 was what caused the crash (it worked correctly under 2.7).

gevent's vendoring modifications were quite small, as I recall, mostly about delaying some imports that interfered with gevent's monkey-patching, and also providing 2.6 compatibility before tblib proper got it.

Oh, also, @Ivoz suggested that ctypes has had some issues under Cygwin Python, so that may be part of it.

Suite passes on 32bit cygwin (py34). Gonna try the 64bit one later but in gevent/gevent#763 @rossengeorgiev seems to run 32bit python on 64bit cygwin - is that correct?

I'm not really sure how to interpret this comment (I know nothing about Cygwin) but I thought that was 64 bit Python. Gonna need some help from @rossengeorgiev

@ionelmc Should be 64bit python, on cygwin64 and windows 10.

$ python3 -c 'import platform; print(platform.architecture())'
('64bit', 'WindowsPE')

I was thinking of spinning a VM and trying 32bit cygwin to see if that made a difference.

Ok, I've reduced the crasher to this:

Python 3.4.3 (default, May  5 2015, 17:58:45)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.pythonapi.Py_InitModule4_64
[1]    2564 segmentation fault (core dumped)  python3

That's pretty amazing. So it looks like a Cygwin/ctypes issue? Not sure what we can do about this? Other than attempt to avoid the feature use downstream.

Well I have found this https://www.cygwin.com/ml/cygwin/2014-11/msg00558.html but no one replied :(

Seems like a long standing issue ...

Accessing existing symbols works:

Python 3.4.3 (default, May  5 2015, 17:58:45)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.pythonapi.Py_OptimizeFlag
<_FuncPtr object at 0x6ffffb59110>

Looks like this is the issue: https://bugs.python.org/issue23338

Cygwin just didn't make binaries with the fixes yet.

I'm willing to consider a workaround (if any was even possible) but I'd rather just wait for cygwin to release newer binaries.

i tend to agree. Thanks for looking into this issue.

I just tried cygwin32 and it works as expected on both py2 & py3. Thanks for all the effort guys, hopefully cygwin will update the packages eventually.

There are now newer versions of both Python 3.4.5 and 3.6.1 provided by cygwin for 64-bits.

I think this can be closed.