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

Peasy segfaults python3 based plugin #4

Closed
sagarchalise opened this issue Jan 22, 2018 · 9 comments
Closed

Peasy segfaults python3 based plugin #4

sagarchalise opened this issue Jan 22, 2018 · 9 comments

Comments

@sagarchalise
Copy link

This may be due to my limited understanding of C programming but I have a plugin that uses python3 directly. https://github.com/sagarchalise/geany-pyjedi

What it basically does is gives autocompletion feature based on jedi module rather than tags that geany originally does.

But if I try to use it with peasy enabled it gives me segfault.

P.S. Actually, if scintilla_send_message can be directly used then I may port this workflow to peasy. But I couldnot get it working and according to this discussion it may be quite difficult: codebrainz/geanypy#32

@kugel-
Copy link
Owner

kugel- commented Jan 22, 2018 via email

@sagarchalise
Copy link
Author

@kugel- actually I tried scintilla_send_message with https://docs.python.org/3/library/ctypes.html. I couldnot find uintptr_t/intptr_t so I cast it to long but its not working. Its not crashing but nothing happens.

@kugel-
Copy link
Owner

kugel- commented Jan 22, 2018

I suggest you run geany in gdb, breaking in scintilla_send_message (perhaps with the condition set to your message id), and verify that the pointer is passed correctly.

Also, I'm confused. https://github.com/sagarchalise/geany-pyjedi is a C plugin isn't it?

@sagarchalise
Copy link
Author

@kugel- yeah but if it does what I am trying to do, I would rather port it to peasy. I have those codes locally but since they are not working have not pushed them to github. Maybe I will push them to peasy branch in the same repo. The pyjedi C plugin crashed if I enable peasy. It seems due to python runtime

@kugel-
Copy link
Owner

kugel- commented Jan 22, 2018

Well, either you debug this or give me enough information so that I can try it locally. Perhaps give me your plugin or a reduced example case so that I can reproduce it on my side.

@kugel-
Copy link
Owner

kugel- commented Jan 22, 2018

I succesfully tried the following in the python terminal that is shipped with peasy (do you have discovered that already?). I've got the autocompletion list. Does that help you?

import ctypes
from ctypes import *

sci = Geany.Document.get_current().editor.sci
list = c_char_p("foo\nbar".encode("utf8"))
# cast to get the pointer value as int
list_p = cast(list, c_void_p).value
sci.send_message(GeanyScintilla.SCI_AUTOCSHOW, 0, list_p)

Closing with sci.send_message(GeanyScintilla.SCI_AUTOCCANCEL, 0, 0) works as well.

@sagarchalise
Copy link
Author

sagarchalise commented Jan 23, 2018

@kugel- thanks I am giving it a try. I have just one question since python strings are unicodes can I use c_wchar_p on strings rather than c_char_p?

Also, the other issue I posted is not really working. I cannot get plugins to show from $HOME/.config/geany/plugins folder.
Also, I am using gtk3 build and not all plugins are showing in plugin manager. Modeline, doxygen and quickswitch are not showing.
Also, In the plugin manager, peasy plugins donot persist. i.e my plugins when I check on enable hide totally from plugin manager. They are enabled for that session but when I restart geany I need to reenable them. Also, I couldnot understand the hiding issue. This doesnot happen for all plugins but only for my custom plugins.

Also I get Can't load plugin: libpeasy.so.0: cannot open shared object file: No such file or directory in ubuntu when I build this. I have to manually link libpeasy.so.0 to /usr/lib folder to get this working.

@kugel-
Copy link
Owner

kugel- commented Jan 23, 2018 via email

@sagarchalise
Copy link
Author

Seems to work.. thanks.
I will post other issues I have.
I think some of the issues are not really issues but my limited understanding of peasy

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

2 participants