You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, when I run test_c_reader.py on Windows the Python interpreter crashes with no specified error.
I'll update this more once I have more details, but I just wanted to make sure to note it before I forget (this is important though as it basically makes Windows testing impossible until it's resolved (or those tests are skipped)).
Relatedly, tokenizer.c does not compile with MSVC. When I sent this report I had compiled it with gcc (via mingw32), but I just thought I'd see if compiling with MSVC made any difference, and it didn't compile at all:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Ic:\Python27\lib\site-packages\numpy\core\include -Ic:\Python27\include -Ic:\Python27\PC /Tcastropy\io\ascii\src\tokenizer.c /Fobuild\temp.win32-2.7\Release\astropy\io\ascii\src\tokenizer.obj
tokenizer.c
astropy\io\ascii\src\tokenizer.c(92) : error C2054: expected '(' to follow 'inline'
astropy\io\ascii\src\tokenizer.c(93) : error C2085: 'push' : not in formal parameter list
astropy\io\ascii\src\tokenizer.c(93) : error C2143: syntax error : missing ';' before '{'
astropy\io\ascii\src\tokenizer.c(121) : error C2054: expected '(' to follow 'inline'
astropy\io\ascii\src\tokenizer.c(122) : error C2085: 'end_field' : not in formal parameter list
astropy\io\ascii\src\tokenizer.c(122) : error C2143: syntax error : missing ';'
before '{'
astropy\io\ascii\src\tokenizer.c(160) : error C2054: expected '(' to follow 'inline'
astropy\io\ascii\src\tokenizer.c(162) : error C2085: 'end_line' : not in formal
parameter list
astropy\io\ascii\src\tokenizer.c(162) : error C2143: syntax error : missing ';'
before '{'
astropy\io\ascii\src\tokenizer.c(323) : warning C4013: 'end_field' undefined; assuming extern returning int
astropy\io\ascii\src\tokenizer.c(381) : warning C4013: 'push' undefined; assuming extern returning int
astropy\io\ascii\src\tokenizer.c(389) : warning C4013: 'end_line' undefined; assuming extern returning int
astropy\io\ascii\src\tokenizer.c(683) : warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
astropy\io\ascii\src\tokenizer.c(783) : warning C4018: '>=' : signed/unsigned mismatch
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Probably something related to what dialect of C it's using compared to the default for gcc (or clang for that matter).
The test still crashes when compiled with MSVC though--I didn't think it was the compiler anyways. Apparently this is something pretty basic because it crashes right in the first test on:
I don't have a debug build of Python on Windows right now, but this is what I got:
Program received signal SIGSEGV, Segmentation fault.
0x1e00fee2 in python27!PyString_FromString ()
from C:\Windows\SysWOW64\python27.dll
(gdb) where
#0 0x1e00fee2 in python27!PyString_FromString ()
from C:\Windows\SysWOW64\python27.dll
#1 0x680470d4 in __pyx_pf_7astropy_2io_5ascii_7cparser_7CParser_16__reduce__
(__pyx_v_self=0x35d7e68) at astropy\io\ascii\cparser.c:12221
#2 __pyx_pw_7astropy_2io_5ascii_7cparser_7CParser_17__reduce__ (
__pyx_v_self=0x35d7e68, unused=0x0) at astropy\io\ascii\cparser.c:12189
#3 0x1e015d93 in python27!PyCFunction_Call ()
from C:\Windows\SysWOW64\python27.dll
The segfault is in PyString_FromString, but it's being called from CParser.__reduce__. Specifically, the line from the generated C code is:
I'm not convinced it's anything so deep as that though. That is, I don't think it's necessary to make any zany patches to multiprocessing or anything. We just need to get __reduce__ working properly. That could be tested even without Windows (just make a CParser object and manually call __reduce__ on it).
Oh, that patch isn't mine 😃 That's just a newly added convenience to replicate Windows behavior on Linux/Mac. You're right, it's actually not strictly necessary to test this out.
Unfortunately that does not fix it--but I didn't expect it would. The problem occurs even before _cparser_copy is called. Even if _cparser_copy expects a Python bytes object the char * needs to be converted to one first via PyBytes_FromString (or the equivalent) and that's where the segfault is occurring.
@AmrAS1 I tried out your fix on Windows and it no longer segfaults, so that's a start. Unfortunately the multiprocessing still doesn't work properly on Windows. It just hangs for a very long time--I'm not sure what it's doing. But that gets back to what you were saying about sketchy multiprocessing support on Windows.
I think that until we can get to the bottom of this and work out a good solution we should just disable the multiprocessing support on Windows and mark any tests that use it as xfail on Windows, because in the meantime it's impossible to run the tests on Windows because of this :(
@embray - I agree, that makes sense. I'll try to figure out what's going on (hopefully pretty soon), but for now I'll just open a PR to disable multiprocessing testing on Windows. All fast-reading tests use multiprocessing, so I think I should just alter those instead of marking them as xfail.
@AmrAS1@embray - as part of disabling the multiprocessing testing on windows, should we also make the parallel option emit a warning (on windows only) that windows support for parallel may have problems? This could be backed out later if a good solution is found, but maybe it's better to not have a serious known problem lurking in master.
@taldcroft@AmrAS1 I was suggesting that in addition to the tests, the parallel option itself should be disabled entirely on Windows, emmitting a NotImplemented exception or such. Anything I try to do it just hangs my system.
I think so--I still have a lot of test failures for io.ascii on Windows, but at least it's not segfaulting or otherwise crashing the Python interpreter.
Activity
embray commentedon Sep 16, 2014
(suggested "Effort-medium" for now, until and unless I figure out what the actual problem is)
embray commentedon Sep 16, 2014
Relatedly,
tokenizer.cdoes not compile with MSVC. When I sent this report I had compiled it with gcc (via mingw32), but I just thought I'd see if compiling with MSVC made any difference, and it didn't compile at all:Probably something related to what dialect of C it's using compared to the default for gcc (or clang for that matter).
astrofrog commentedon Sep 17, 2014
cc @AmrAS1 @taldcroft
embray commentedon Sep 17, 2014
I tracked down the MSVC issue. No big deal there.
The test still crashes when compiled with MSVC though--I didn't think it was the compiler anyways. Apparently this is something pretty basic because it crashes right in the first test on:
embray commentedon Sep 17, 2014
Digging a little deeper, it's specifically in parallel=True where it blows up.
mdmueller commentedon Sep 17, 2014
Hm...do you have the full error output available, or is it a segfault?
embray commentedon Sep 17, 2014
I'm checking on that now. It looks like it's a segfault.
embray commentedon Sep 17, 2014
I don't have a debug build of Python on Windows right now, but this is what I got:
The segfault is in
PyString_FromString, but it's being called fromCParser.__reduce__. Specifically, the line from the generated C code is:so it looks like maybe
source_ptrcontains a bad address.embray commentedon Sep 17, 2014
(Indeed,
self.source_ptris NULL here)2 remaining items
embray commentedon Sep 17, 2014
I'm not convinced it's anything so deep as that though. That is, I don't think it's necessary to make any zany patches to multiprocessing or anything. We just need to get
__reduce__working properly. That could be tested even without Windows (just make a CParser object and manually call__reduce__on it).embray commentedon Sep 17, 2014
That would explain though why this is only showing up on Windows.
mdmueller commentedon Sep 17, 2014
Oh, that patch isn't mine 😃 That's just a newly added convenience to replicate Windows behavior on Linux/Mac. You're right, it's actually not strictly necessary to test this out.
mdmueller commentedon Sep 17, 2014
@embray - Does this work? It should fix the segfault but I haven't been able to check yet if the tests will still pass.
embray commentedon Sep 17, 2014
Unfortunately that does not fix it--but I didn't expect it would. The problem occurs even before
_cparser_copyis called. Even if_cparser_copyexpects a Pythonbytesobject thechar *needs to be converted to one first viaPyBytes_FromString(or the equivalent) and that's where the segfault is occurring.I found you can reproduce this easily on Linux:
mdmueller commentedon Sep 17, 2014
@embray -
CParser(None, 0, 0).__reduce__()works for me with the altered version. The relevant difference is this: https://github.com/amras1/astropy/compare/fix-cparser-reduce#diff-46d96e60712ec8a415ed95737bd279d3R723embray commentedon Sep 18, 2014
Oh, somehow I missed that change. That looks feasible. I'll give it a try.
embray commentedon Sep 22, 2014
@AmrAS1 I tried out your fix on Windows and it no longer segfaults, so that's a start. Unfortunately the multiprocessing still doesn't work properly on Windows. It just hangs for a very long time--I'm not sure what it's doing. But that gets back to what you were saying about sketchy multiprocessing support on Windows.
I think that until we can get to the bottom of this and work out a good solution we should just disable the multiprocessing support on Windows and mark any tests that use it as xfail on Windows, because in the meantime it's impossible to run the tests on Windows because of this :(
mdmueller commentedon Sep 22, 2014
@embray - I agree, that makes sense. I'll try to figure out what's going on (hopefully pretty soon), but for now I'll just open a PR to disable multiprocessing testing on Windows. All fast-reading tests use multiprocessing, so I think I should just alter those instead of marking them as xfail.
taldcroft commentedon Sep 22, 2014
@AmrAS1 @embray - as part of disabling the multiprocessing testing on windows, should we also make the
paralleloption emit a warning (on windows only) that windows support for parallel may have problems? This could be backed out later if a good solution is found, but maybe it's better to not have a serious known problem lurking in master.mdmueller commentedon Sep 22, 2014
@taldcroft - That sounds good to me. I'll add this as a commit in #2969.
embray commentedon Sep 22, 2014
@taldcroft @AmrAS1 I was suggesting that in addition to the tests, the
paralleloption itself should be disabled entirely on Windows, emmitting aNotImplementedexception or such. Anything I try to do it just hangs my system.taldcroft commentedon Dec 20, 2014
@embray - can this be closed?
embray commentedon Dec 22, 2014
I think so--I still have a lot of test failures for
io.asciion Windows, but at least it's not segfaulting or otherwise crashing the Python interpreter.