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

io tests crash on Windows #5540

Closed
ev-br opened this issue Nov 25, 2015 · 29 comments
Closed

io tests crash on Windows #5540

ev-br opened this issue Nov 25, 2015 · 29 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.io

Comments

@ev-br
Copy link
Member

ev-br commented Nov 25, 2015

test_mio.test_load('double', ['C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_4.2c_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.1_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.5.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.4_GLNX86.mat'], {'testdouble': array([[ 0.        ,  0.78539816,  1.57079633,  2.35619449,  3.14159265, ... 

Windows XP, numpy-vendor binaries.

@ev-br ev-br added scipy.io defect A clear bug or issue that prevents SciPy from being installed or used as expected labels Nov 25, 2015
@ev-br ev-br added this to the 0.17.0 milestone Nov 25, 2015
@rgommers
Copy link
Member

Hmm, very little changed in io.matlab for this release. Do the 0.16.1 binaries crash as well?

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

io tests pass for 0.16.1 binaries from github releases.
With binaries for yesterday's master, I tracked this down to https://github.com/scipy/scipy/blob/master/scipy/io/matlab/mio.py#L135 which seems to suggest #5082
@matthew-brett @anntzer any ideas?

@matthew-brett
Copy link
Contributor

@ev-br - can you post a more complete log? Would it be easy to post a binary somewhere for me to test?

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

I've posted the binary at https://github.com/scipy/scipy/releases/tag/v0.17pre
(This seemed to "create a release", whatever is meant by Github; I'm not sure what sort of publicity it entails; if that's undesirable, I'll immediately remove it and send you a dropbox link or something.)

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

Regarding a more complete log, I'm not sure what it would be. I just ran scipy.test(verbose=10) and then walked it a bit in pdb. What sort of info would be useful for you?

@matthew-brett
Copy link
Contributor

I was thinking of something like the complete log from nosetests /path/to/scipy/install/scipy/io/matlab/tests/test_mio.py:test_load

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

Under Wine this apparently just hangs:

vagrant@vagrant-ubuntu-precise-32:~$ .wine/drive_c/Python27/Scripts/nosetests.exe .wine/drive_c/Python27/Lib/site-packages/scipy/io/matlab/renamed/test_mio.py:test_load
^Cerr:console:GenerateConsoleCtrlEvent Invalid event 46 for PGID 0
^Cerr:console:GenerateConsoleCtrlEvent Invalid event 46 for PGID 0
^Cerr:console:GenerateConsoleCtrlEvent Invalid event 46 for PGID 0
^Cerr:console:GenerateConsoleCtrlEvent Invalid event 46 for PGID 0

In a different window:

vagrant@vagrant-ubuntu-precise-32:~$ ps ax | grep nosetests
 2828 pts/0    S+     0:00 .wine/drive_c/Python27/Scripts/nosetests.exe .wine/drive_c/Python27/Lib/site-packages/scipy/io/matlab/renamed/test_mio.py:test_load                                      
 2831 pts/0    S+     2:40 C:\Python27\python.exe Z:\home\vagrant\.wine\drive_c\Python27\Scripts\nosetests-script.py .wine/drive_c/Python27/Lib/site-packages/scipy/io/matlab/renamed/test_mio.py:test_load

only reacts to kill -9.

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

Under WIndows it crashes, I'll be able to post the exact details in the morning local time.

@matthew-brett
Copy link
Contributor

Just to be sure - if you build scipy 0.16.1 with the same setup, you get no such crash, and all tests pass?

@ev-br
Copy link
Member Author

ev-br commented Nov 26, 2015

OK, something's not right with my build setup. If I take official superpack installers, all io tests pass.

If I build 0.16.1, I get the same crash:

>>> io.test(verbose=10)
Running unit tests for scipy.io
NumPy version 1.7.2
NumPy is installed in C:\Python27\lib\site-packages\numpy
SciPy version 0.16.1
SciPy is installed in C:\Python27\lib\site-packages\scipy
Python version 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
nose version 1.3.7
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.config: INFO: Excluding tests matching ['f2py_ext', 'f2py_f90_ext', 'gen_ext', 'pyrex_ext', 'swig_ext']
test1 (test_arffread.DataTest) ... ok
test2 (test_arffread.DataTest) ... ok
test3 (test_arffread.DataTest) ... ok
test_filelike (test_arffread.DataTest) ... ok
test_date_attribute (test_arffread.DateAttributeTest) ... ok
test_datetime_local_attribute (test_arffread.DateAttributeTest) ... ok
test_datetime_missing (test_arffread.DateAttributeTest) ... ok
test_datetime_timezone (test_arffread.DateAttributeTest) ... ok
test_month_attribute (test_arffread.DateAttributeTest) ... ok
test_year_attribute (test_arffread.DateAttributeTest) ... ok
test_badtype_parsing (test_arffread.HeaderTest) ... ok
test_dateheader (test_arffread.HeaderTest) ... ok
test_dateheader_unsupported (test_arffread.HeaderTest) ... ok
test_fullheader1 (test_arffread.HeaderTest) ... ok
test_type_parsing (test_arffread.HeaderTest) ... ok
test_missing (test_arffread.MissingDataTest) ... ok
test_from_number (test_fortran_format.TestExpFormat) ... ok
test_to_fortran (test_fortran_format.TestExpFormat) ... ok
test_exp_exp (test_fortran_format.TestFortranFormatParser) ... ok
test_repeat_exp (test_fortran_format.TestFortranFormatParser) ... ok
test_repeat_exp_exp (test_fortran_format.TestFortranFormatParser) ... ok
test_simple_exp (test_fortran_format.TestFortranFormatParser) ... ok
test_simple_int (test_fortran_format.TestFortranFormatParser) ... ok
test_simple_repeated_int (test_fortran_format.TestFortranFormatParser) ... ok
test_wrong_formats (test_fortran_format.TestFortranFormatParser) ... ok
test_from_number (test_fortran_format.TestIntFormat) ... ok
test_to_fortran (test_fortran_format.TestIntFormat) ... ok
test_simple (test_hb.TestHBReader) ... ok
test_simple (test_hb.TestRBRoundtrip) ... ok
test_byteordercodes.test_native ... ok
test_byteordercodes.test_to_numpy ... ok
test_mio.test_load('double', ['C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_4.2c_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.1_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.5.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.4_GLNX86.mat'], {'testdouble': array([[ 0.        ,  0.78539816,  1.57079633,  2.35619449,  3.14159265, ... 

... "pythonw.exe encountered a problem and needs to close."

Hmm...
What does the binary from up thread do on your machine Matthew?

@matthew-brett
Copy link
Contributor

matthew-brett commented Nov 27, 2015 via email

@ev-br
Copy link
Member Author

ev-br commented Nov 27, 2015

Happy Thanksgiving!

@matthew-brett
Copy link
Contributor

I installed your installer, using the numpy superpack installer for numpy. I also get a crash for test_mio.py.

The scipy 0.16.1 installer downloaded from SF also works fine for me.

@ev-br
Copy link
Member Author

ev-br commented Nov 29, 2015

OK, I tried building scipy versions down to 0.15.1 and with cython 0.23.4 or 0.22, and they all crash. Now, this seems to point to a problem in my setup, but it's just an unmodified numpy/numpy-vendor#10. At this stage, I'd appreciate any help or any sort of pointers.

@rgommers
Copy link
Member

I'll try to reproduce tonight.

@rgommers
Copy link
Member

rgommers commented Dec 1, 2015

Hmm, reproduced, but not yet clear what changed. The only thing I can think of right now is the switch from Cython 0.20.0 to 0.22.0 and then 0.23.4.

@ev-br
Copy link
Member Author

ev-br commented Dec 1, 2015

OK, just as a data point: I downgraded to Cython 0.20.0 and build scipy 0.15.1 with it. (I don't think later scipy versions could be built with it, can they). Under Wine, the problem shows up as a deadlock.

>>> import scipy.io.matlab as iom
>>> iom.test(verbose=10)
Running unit tests for scipy.io.matlab
NumPy version 1.6.2
NumPy is installed in C:\Python27\lib\site-packages\numpy
SciPy version 0.15.1
SciPy is installed in C:\Python27\lib\site-packages\scipy
Python version 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
nose version 1.1.2
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.config: INFO: Excluding tests matching ['f2py_ext', 'f2py_f90_ext', 'gen_ext', 'pyrex_ext', 'swig_ext']
nose.config: INFO: Excluding tests matching ['f2py_ext', 'f2py_f90_ext', 'gen_ext', 'pyrex_ext', 'swig_ext']
test_byteordercodes.test_native ... ok
test_byteordercodes.test_to_numpy ... ok
test_mio.test_load('double', ['C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.5.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_6.1_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.1_GLNX86.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_4.2c_SOL2.mat', 'C:\\Python27\\lib\\site-packages\\scipy\\io\\matlab\\tests\\data\\testdouble_7.4_GLNX86.mat'], {'testdouble': array([[ 0.        ,  0.78539816,  1.57079633,  2.35619449,  3.14159265, ... err:ntdll:RtlpWaitForCriticalSection section 0x785b7428 "?" wait timed out in thread 0009, blocked by 0000, retrying (60 sec)
err:ntdll:RtlpWaitForCriticalSection section 0x785b7428 "?" wait timed out in thread 0009, blocked by 0000, retrying (60 sec)
err:ntdll:RtlpWaitForCriticalSection section 0x785b7428 "?" wait timed out in thread 0009, blocked by 0000, retrying (60 sec)

Not sure if this makes it any clearer...

@rgommers
Copy link
Member

rgommers commented Dec 1, 2015

I think the issue is with np.fromfile here. Can reproduce it also with cluster/test_vq.py which has fromfile uses. I'll see if I can prove and work around it.

rgommers added a commit to rgommers/scipy that referenced this issue Dec 1, 2015
This change is faster (avoids multiple times reading of the same file),
and may avoid a hang of the test suite under Wine (see scipygh-5540).
@rgommers
Copy link
Member

rgommers commented Dec 1, 2015

https://github.com/rgommers/scipy/tree/remove-fromfile fixes one crash in cluster. I misread test_mmio for test_mio. io/matlab doesn't contain a call to fromfile. So will have to dig a bit deeper for that one. Good chance it's related though, symptoms are identical.

@rgommers
Copy link
Member

rgommers commented Dec 2, 2015

OK, I see the same thing in the numpy tests and in other tests that use np.load and np.fromfile at least. If I download a numpy 1.6.2 superpack from SF and install that, the numpy issues and all scipy issues except the test_mio.test_load one are gone. The 1.6.2 binaries on SF were built with an older Wine version, that's the only difference AFAIK.

So the good news is that we narrowed it down a bit, the bad news that this is still not going to be fun.

@rgommers
Copy link
Member

rgommers commented Dec 2, 2015

From vague memories: there are issues with file handles and fseek/ftell. The io.matlab code that looks suspicious here is the use of npy_PyFile_Dup and npy_PyFile_DupClose. Those have been removed from numpy in 1.10.0, but are still used in streams.pyx. These functions seem to be copied from numpy into io/matlab/py3k.h. That file was never touched after initial creation when we first started supporting Python 3.x.

@rgommers
Copy link
Member

rgommers commented Dec 2, 2015

Just checked: np.fromfile uses npy_PyFile_DupClose2 and np.load uses fromfile under the hood - all the same issue it looks like.

@rgommers
Copy link
Member

rgommers commented Dec 2, 2015

rgommers added a commit to rgommers/scipy that referenced this issue Dec 3, 2015
This change is faster (avoids multiple times reading of the same file),
gets rid of a data file that's not really needed, and may avoid issues with
np.fromfile (under Wine for example, see scipygh-5540).
@ev-br
Copy link
Member Author

ev-br commented Dec 17, 2015

It's not fun indeed, but it seems a bit different of an issue here. The numpy issues relate to python 3, but here python 3 is actually fine, the crash is on python 2.7.

On python 2, npy_PyFile_Dup et al are just aliases to functions from Python.h.
I tried to avoid using them and use the numpy replacements on python 2: master...ev-br:io_crash
And it does not crash --- there are "just" 70-odd copies of

======================================================================
ERROR: test_mio.test_read_both_endian
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\nose-1.1.2-py2.7.egg\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "Z:\home\vagrant\.wine\drive_c\Python27\Lib\site-packages\scipy\io\matlab\tests\test_mio.py", line 904, in test_read_both_endian
    d = rdr.get_variables()
  File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 268, in get_variables
    self.initialize_read()
  File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 196, in initialize_read
    self._file_reader = VarReader5(self)
  File "scipy/io/matlab/mio5_utils.pyx", line 191, in scipy.io.matlab.mio5_utils.VarReader5.__cinit__ (scipy\io\matlab\mio5_utils.c:2846)
  File "scipy/io/matlab/mio5_utils.pyx", line 214, in scipy.io.matlab.mio5_utils.VarReader5.set_stream (scipy\io\matlab\mio5_utils.c:3358)
  File "scipy/io/matlab/streams.pyx", line 360, in scipy.io.matlab.streams.make_stream (scipy\io\matlab\streams.c:5543)
SystemError: NULL result without error in PyObject_Call

Full log: https://gist.github.com/ev-br/63a0473bcc84820190a1

This seems to point to some CRT incompatibility? https://mail.scipy.org/pipermail/numpy-discussion/2012-July/063414.html

@pv
Copy link
Member

pv commented Dec 17, 2015

Some issues:
.

  • The Python 2 code is indeed obtaining FILE* handles from the CRT
    Python uses and passing them to whatever CRT Scipy uses. This problem
    probably manifests already with numpy.fromfile, built in same way?
    .
  • The call to *DupClose in streams.pyx:FileStream.__del__ is not
    guarded for the case where initialization in __init__ fails.
    .
  • The routines in py3k.h should be synced with Numpy. However, I don't
    think this is related to this crash, since on Python 2 it's just
    #defines for the Python C-API.
    .
  • If the issue is some CRT issue, then I think one should avoid adding
    workarounds, and try to understand why the build environment produces
    incorrect binaries.

@rgommers
Copy link
Member

For the record, my ancient Wine 1.1.39 setup doesn't have this issue. Something got messed up in numpy-vendor.

@rgommers
Copy link
Member

rgommers commented Jan 3, 2016

We're not producing win32 binaries for 0.17.0, so removing the 0.17.0 milestone.

Leaving the issue open because there's some things to do - see comment @pv above.

@rgommers rgommers removed this from the 0.17.0 milestone Jan 3, 2016
@pv
Copy link
Member

pv commented Feb 22, 2016

Maybe related: #5882 (Anaconda binaries)

@sethtroisi
Copy link
Contributor

I believe that all of the mentioned issues above have been resolved.

  • Python2 no longer supported
  • DupClose in streams.pyx removed in favor of GenericStream
  • py3k.h all removed (and numpy_py3k.h almost completely gone)
  • windows 32 binaries gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.io
Projects
None yet
Development

No branches or pull requests

5 participants