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

Segfault on Windows due to PyCall #327

Closed
ChrisRackauckas opened this issue Oct 27, 2016 · 5 comments
Closed

Segfault on Windows due to PyCall #327

ChrisRackauckas opened this issue Oct 27, 2016 · 5 comments

Comments

@ChrisRackauckas
Copy link

I am writing a wrapper for PyDSTool and the test code can be found here. I made a special install path to get it installed on Windows and when I do

using Conda
joinpath(Conda.PYTHONDIR, "python")

I get C:\Users\Chris\.julia\v0.6\Conda\deps\usr\python, so I check in the terminal:

C:\Users\Chris>C:\Users\Chris\.julia\v0.6\Conda\deps\usr\python
Python 3.5.2 | packaged by conda-forge | (default, Jul 26 2016, 02:06:09) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyDSTool import *
Warning: matplotlib failed to import properly and so is not
  providing a graphing interface
>>> icdict = {'x': 1, 'y': 0.4}
>>> pardict = {'k': 0.1, 'm': 0.5}
>>> x_rhs = 'y'
>>> y_rhs = '-k*x/m'
>>> vardict = {'x': x_rhs, 'y': y_rhs}
>>> DSargs = args()                   # create an empty object instance of the args class, call it DSargs
>>> DSargs.name = 'SHM'               # name our model
>>> DSargs.ics = icdict               # assign the icdict to the ics attribute
>>> DSargs.pars = pardict             # assign the pardict to the pars attribute
>>> DSargs.tdata = [0, 20]            # declare how long we expect to integrate for
>>> DSargs.varspecs = vardict         # assign the vardict dictionary to the 'varspecs' attribute of DSargs
>>> DS = Generator.Vode_ODEsystem(DSargs)
>>> traj = DS.compute('demo')
>>> pts = traj.sample()
>>> pts['t']
array([  0.00000000e+00,   1.00050025e-02,   2.00100050e-02, ...,
         1.99799900e+01,   1.99899950e+01,   2.00000000e+01])

That the Python setup in Windows works. I know that the PyCall wrapper code works (tested on Linux). However, when I try that same code on Windows through PyCall, I get a segfault at the first usage of PyDSTool (exported as ds) with the command: DSargs = ds.args(). The message is as follows:

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5c084974 -- PySequence_Size at C:\Users\Chris\.julia\v0.6\Conda\deps\usr\python35.DLL (unknown line)
while loading C:\Users\Chris\.julia\v0.6\PyDSTool\test\linear.jl, in expression starting on line 14
PySequence_Size at C:\Users\Chris\.julia\v0.6\Conda\deps\usr\python35.DLL (unknown line)
macro expansion at C:\Users\Chris\.julia\v0.6\PyCall\src\exception.jl:78 [inlined]
start at C:\Users\Chris\.julia\v0.6\PyCall\src\conversions.jl:504
copy at .\associative.jl:108
convert at C:\Users\Chris\.julia\v0.6\PyCall\src\conversions.jl:563
unknown function (ip: 0000000007AC964A)
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
convert at C:\Users\Chris\.julia\v0.6\PyCall\src\conversions.jl:806
#pycall#66 at C:\Users\Chris\.julia\v0.6\PyCall\src\PyCall.jl:568
#call#67 at C:\Users\Chris\.julia\v0.6\PyCall\src\PyCall.jl:571
PyObject at C:\Users\Chris\.julia\v0.6\PyCall\src\PyCall.jl:571
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
do_call at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:71
eval at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:210
eval_body at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:484
jl_interpret_toplevel_thunk at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:628
jl_toplevel_eval_flex at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\toplevel.c:642
jl_parse_eval_all at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\ast.c:735
include_string at .\loading.jl:478
include_string at C:\Users\Chris\.julia\v0.6\CodeTools\src\eval.jl:28
unknown function (ip: 0000000007A8ADD5)
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
do_call at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:71
eval at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\interpreter.c:210
jl_toplevel_eval_flex at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\toplevel.c:628 [inlined]
jl_toplevel_eval at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\toplevel.c:650
jl_toplevel_eval_in at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\builtins.c:577
include_string at C:\Users\Chris\.julia\v0.6\CodeTools\src\eval.jl:32
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
#49 at C:\Users\Chris\.julia\v0.6\Atom\src\eval.jl:40
withpath at C:\Users\Chris\.julia\v0.6\CodeTools\src\utils.jl:30
unknown function (ip: 0000000007A8A7DA)
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
withpath at C:\Users\Chris\.julia\v0.6\Atom\src\eval.jl:46
unknown function (ip: 0000000007A8A42A)
macro expansion at C:\Users\Chris\.julia\v0.6\Atom\src\eval.jl:57 [inlined]
#48 at .\task.jl:60
jl_call_method_internal at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia_internal.h:239 [inlined]
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\gf.c:1861
jl_apply at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\julia.h:1378 [inlined]
start_task at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\task.c:259
Allocations: 6733384 (Pool: 6732036; Big: 1348); GC: 11
@ChrisRackauckas
Copy link
Author

ChrisRackauckas commented Oct 27, 2016

Could this be related: http://www.ni.gsu.edu/~rclewley/PyDSTool/GettingStarted.html

IMPORTANT FOR WINDOWS USERS: The Numpy dependency is not yet properly supported on 64-bit Windows platforms. Although a third-party installer such as Anaconaa will install, it will not have the correct header files to allow distutils to work with PyDSTool to build C-based vector field definitions. You must install your whole python-numpy-scipy-matplotlib stack in 32-bit mode to enable access to these features!

From the command line you can see that it works already though...

@ChrisRackauckas
Copy link
Author

Did a test and this "segfault every time" at the same line occurs on Mac. It seems that Linux tends to segfault more around the lines that these two OS' segfault every time, indicating that this issue may be related to #328

@ChrisRackauckas
Copy link
Author

Even with the change from the other thread. Windows still segfaults:


signal (11): Segmentation fault
while loading /home/crackauc/.julia/v0.5/PyDSTool/test/linear.jl, in expression starting on line 11
PySequence_Size at /home/ilan/minonda/conda-bld/work/Python-2.7.12/Objects/abstract.c:1867
macro expansion at /home/crackauc/.julia/v0.5/PyCall/src/exception.jl:78 [inlined]
start at /home/crackauc/.julia/v0.5/PyCall/src/conversions.jl:504
copy at ./dict.jl:124
convert at /home/crackauc/.julia/v0.5/PyCall/src/conversions.jl:563
unknown function (ip: 0x7f21e1ae2c96)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
convert at /home/crackauc/.julia/v0.5/PyCall/src/conversions.jl:806
#pycall#66 at /home/crackauc/.julia/v0.5/PyCall/src/PyCall.jl:568
#call#67 at /home/crackauc/.julia/v0.5/PyCall/src/PyCall.jl:571
PyObject at /home/crackauc/.julia/v0.5/PyCall/src/PyCall.jl:571
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
build_ode at /home/crackauc/.julia/v0.5/PyDSTool/src/PyDSTool.jl:44
unknown function (ip: 0x7f21e1ade266)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7f2421f8bb7d)
unknown function (ip: 0x7f2421f8b62e)
unknown function (ip: 0x7f2421f8c1e2)
unknown function (ip: 0x7f2421f8c667)
unknown function (ip: 0x7f2421fa8555)
unknown function (ip: 0x7f2421f80d85)
unknown function (ip: 0x7f24158106d5)
include_string at /home/crackauc/.julia/v0.5/CodeTools/src/eval.jl:28
unknown function (ip: 0x7f21e1aa0d70)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7f2421f8bb7d)
unknown function (ip: 0x7f2421f8b62e)
jl_toplevel_eval at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7f2421f867e3)
include_string at /home/crackauc/.julia/v0.5/CodeTools/src/eval.jl:32
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
#49 at /home/crackauc/.julia/v0.5/Atom/src/eval.jl:40
withpath at /home/crackauc/.julia/v0.5/CodeTools/src/utils.jl:30
unknown function (ip: 0x7f21e1aa0836)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
withpath at /home/crackauc/.julia/v0.5/Atom/src/eval.jl:46
unknown function (ip: 0x7f21e1aa04a6)
macro expansion at /home/crackauc/.julia/v0.5/Atom/src/eval.jl:57 [inlined]
#48 at ./task.jl:60
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7f2421f955d1)
unknown function (ip: 0xffffffffffffffff)
Allocations: 5593932 (Pool: 5592792; Big: 1140); GC: 8

@ChrisRackauckas
Copy link
Author

ChrisRackauckas commented Nov 2, 2016

I ran this in julia-debug and got the following output: https://gist.github.com/ChrisRackauckas/7b24d30ac305affc13d28e9a1b729646 . The code was simply:

using PyDSTool, PyCall
dsargs = ds[:args]()

@ChrisRackauckas
Copy link
Author

Closing this because I think it's a duplicate of #328 . Not sure why Mac/Windows deterministically segfault though, while Linux (CentOS) is non-deterministic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant