[Geany-Devel] Segmentation fault when auto-close plug-in is enable [patch]
mbrush at xxxxx
Wed Oct 23 14:53:16 UTC 2013
On 13-10-23 05:29 AM, n at sk0 wrote:
> Before read : Keep in mind that i am *not* C/C++ "native" developer, and
> all message below can be just rant.
> After little testing and debugging, i found that :
> In on_editor_notify() function, user_data is not a valid pointer :
> on_editor_notify(GObject *obj, gint scn, SCNotification *nt, gpointer
> AutocloseUserData *data = user_data;
> After I playing for a while with this and reading demoplugin.c source, i
> found that in the autoclose.c, PluginCallback (line:829) is missing
> the definition for "editor-notify" event,so i added it, recompile plugin
> and now all seems to work correctly.
It's connected on line 812 inside a callback for when the document is
activated. There's a few problems with this; the data allocated on L810
is going to leak, once for each time a document is activated (has tab
switched to). The other thing is the plugin_signal_connect() is going to
stack up signal handlers, so if you activated a document,
on_editor_notify is going to get called on every single scintilla
notification (keypress, cursor blink, etc.), for every number of times
that document was activated.
The final problem is that, as Lex mentioned, it's not checking
`DOC_VALID()` (or doc->is_valid) but just that data->doc != NULL, so if
any document that was ever activated is closed, this is going to explode
when the document pointer is dereferenced (for reasons I never
understood, Geany "recycles" documents, so it's entirely possible to
have a document pointer that is neither NULL nor valid).
> P.S.: I add the patch file as attachment to this mail, becouse for now i
> do not have any expiriance in commiting patches on GitHub, but tonight i
> will fix this big mistake :)
> On 23/10/13 13:00, Lex Trotman wrote:
>> Looking at the line that failed, first guess would be failure to check
>> doc is valid before using it.
>> On 23 October 2013 20:20, n at sk0 <arrtedone at gmail.com
>> <mailto:arrtedone at gmail.com>> wrote:
>> There is strange behaviour when Auto-close plug-in is enabled.
>> Steps to reproduce :
>> 1. open Geany
>> 2. Enable auto-close plug-in
>> 3. open several files for edit
>> 4. Click Ctrl+W (close document)
>> Expected result :
>> Currently opened document is closed.
>> Actual result :
>> Segmentation fault
>> See attached gdb backtrace for more info.
>> Debug info :
>> Geany-INFO: Geany 1.24 (git >= ef33175), en_US.UTF-8
>> Geany-INFO: GTK 2.24.22, GLib 2.36.3
>> Geany-INFO: System data dir: /usr/local/share/geany
>> Geany-INFO: User config dir: /home/nask0/.config/geany
>> Geany-INFO: System plugin path: /usr/local/lib/geany
>> Geany-INFO: Added filetype CUDA (57).
>> Geany-INFO: Added filetype Rust (58).
>> Geany-INFO: Added filetype Scala (59).
>> Geany-INFO: Added filetype Graphviz (60).
>> Geany-INFO: Added filetype Cython (61).
>> Geany-INFO: Added filetype Genie (62).
>> Geany-INFO: Added filetype Clojure (63).
>> Geany-INFO: Added filetype Go (64).
>> Geany-INFO: Disabling terminal support
>> Geany-INFO: Loaded: /usr/local/lib/geany/addons.so (Addons)
>> Geany-INFO: Loaded: /usr/local/lib/geany/autoclose.so (Auto-close)
>> Geany-INFO: Loaded: /usr/local/lib/geany/geanylipsum.so
>> Geany-INFO: Loaded: /usr/local/lib/geany/geanyvc.so (GeanyVC)
>> Geany-INFO: Loaded: /usr/local/lib/geany/htmlchars.so (HTML
>> Geany-INFO: Loaded: /usr/local/lib/geany/geanyprj.so (Project)
>> Geany-INFO: Loaded: /usr/local/lib/geany/splitwindow.so (Split
>> Geany-INFO: Loaded: /usr/local/lib/geany/treebrowser.so
>> Geany-INFO: Loaded: /usr/local/lib/geany/xmlsnippets.so (XML
>> Devel mailing list
>> Devel at lists.geany.org <mailto:Devel at lists.geany.org>
>> Devel mailing list
>> Devel at lists.geany.org
> Devel mailing list
> Devel at lists.geany.org
More information about the Devel