Skip to content

IPython shell segfault on tab completion #132

Closed

Description

@simonbyrne

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.

Activity

  1. simonbyrne commented on Nov 14, 2017

    @simonbyrne
    Author

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

  2. stevengj commented on Nov 14, 2017

    @stevengj
    Member

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

  3. zsunberg commented on Nov 28, 2017

    @zsunberg

    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
    
  4. tkf commented on May 13, 2018

    @tkf
    Member

    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

  5. tkf commented on May 13, 2018

    @tkf
    Member

    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()
  6. takluyver commented on May 20, 2018

    @takluyver

    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.

  7. tkf commented on May 20, 2018

    @tkf
    Member

    @takluyver Thanks. That would be awesome.

  8. tkf commented on Jul 31, 2018

    @tkf
    Member

    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

  9. tkf commented on Jul 31, 2018

    @tkf
    Member

    Yes, tab completion in IPython master works with pyjulia!

    image

  10. tkf commented on Oct 20, 2018

    @tkf
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions