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

IPython shell segfault on tab completion #132

Closed
simonbyrne opened this issue Nov 8, 2017 · 10 comments
Closed

IPython shell segfault on tab completion #132

simonbyrne opened this issue Nov 8, 2017 · 10 comments

Comments

@simonbyrne
Copy link

simonbyrne commented Nov 8, 2017

In the ipython shell:

import julia
j = julia.Julia()
j.<tab>

immediately segfaults.

On OS X:

Python 3.6.3 (default, Oct  4 2017, 06:09:05) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.
@simonbyrne
Copy link
Author

Interestingly, it's fine in the normal python3 shell. So maybe it's an IPython issue?

@stevengj
Copy link
Member

IPython does tab completion differently than python3, but it's probably ultimately a pyjulia bug that is being triggered.

@zsunberg
Copy link

On linux with ipython 5.1.0, I am able to do tab completion of methods of the Julia object, but when I try to complete filenames in a string, it segfaults, e.g.

In [1]: import julia

In [2]: j = julia.Julia()

In [3]: j.evalfile("new<tab>
signal (11): Segmentation fault                                               
while loading no file, in expression starting on line 0                       
Segmentation fault

@tkf
Copy link
Member

tkf commented May 13, 2018

As @takluyver guessed in ipython/ipython#10899 (comment), it looks like threading problem. Just in case if someone wants to reproduce the problem in a script, here it is:

import threading

from IPython.testing.globalipapp import get_ipython
from julia import Julia

ip = get_ipython()
ip.user_ns['julia'] = Julia()


def ip_complete():
    print(ip.complete('julia.sin.'))


print("ip_complete() in main thread:")
ip_complete()
print()

print("ip_complete() in different thread:")
th = threading.Thread(target=ip_complete)
th.start()
th.join()

It prints

ip_complete() in main thread:
('julia.sin.', ['julia.sin.jl_value'])

ip_complete() in different thread:

signal (11): Segmentation fault

I wonder if PyCall/libjulia can support multi-thread usage. JuliaLang/julia#17573

@tkf
Copy link
Member

tkf commented May 13, 2018

Of course, producing segfault this way doesn't require IPython:

import threading

from julia import Julia

j = Julia()
j_sin = j.sin


def access_julia():
    j_sin.jl_value


th = threading.Thread(target=access_julia)
th.start()
th.join()

@takluyver
Copy link

When prompt_toolkit version 2 is ready, we (IPython) should be able to do completions in the main thread, which should avoid this kind of issue. A few things have come up that don't like their completions running from another thread.

@tkf
Copy link
Member

tkf commented May 20, 2018

@takluyver Thanks. That would be awesome.

@tkf
Copy link
Member

tkf commented Jul 31, 2018

I just found out that IPython master (to be released as 7.0) already was upgraded to use prompt_toolkit 2.0! ipython/ipython#11177 I have to try it soon...

FYI, here is IPython's 7.0 milestone https://github.com/ipython/ipython/milestone/43

@tkf
Copy link
Member

tkf commented Jul 31, 2018

Yes, tab completion in IPython master works with pyjulia!

image

@tkf
Copy link
Member

tkf commented Oct 20, 2018

IPython 7.0 is already released and available in PyPI and Anaconda. Closing...

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

5 participants