Seems like automark is crashing geany with segmentation fault.
I am using gtk3 built on ubuntu 16.04.
Backtrace:
``` Thread 1 "geany" received signal SIGSEGV, Segmentation fault. automark (user_data=0x3520f90) at automark.c:104 104 ScintillaObject *sci = editor->sci; (gdb) bt #0 automark (user_data=0x3520f90) at automark.c:104 #1 0x00007ffff50de04a in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #2 0x00007ffff50de3f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #3 0x00007ffff50de712 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #4 0x00007ffff6c24395 in gtk_main () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 #5 0x00007ffff799d567 in main_lib (argc=1, argv=0x7fffffffd948) at libmain.c:1233 #6 0x00007ffff7362830 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6 #7 0x00000000004005d9 in _start () ```
Which version of Geany/Geany-Plugins are running there?
Do you have any document open when this crash occurs?
Its from development repo. I haven't studied the pattern but I have experienced this with html, python files.
Well, automark() does not check if the document is still valid, and as its activated by idle-add its possible that the document is no longer valid by the time it is activated.
Yes, we should a check against NULL here.
Looking at the code this seems to have been fixed already:
``` C static gboolean automark(gpointer user_data) { GeanyDocument *doc = (GeanyDocument *)user_data; GeanyEditor *editor = doc->editor; static GeanyEditor *editor_cache = NULL; ScintillaObject *sci = editor->sci; gchar *text; static gchar text_cache[GEANY_MAX_WORD_LENGTH] = {0}; gint match_flag = SCFIND_MATCHCASE | SCFIND_WHOLEWORD; struct Sci_TextToFind ttf;
source_id = 0;
/* during timeout document could be destroyed so check everything again */ if (!DOC_VALID(doc)) return FALSE;
/* Do not highlight while selecting text and allow other markers to work */ if (sci_has_selection(sci)) return FALSE; ```
Can this be closed?
The `DOC_VALID` check needs to be moved up before the 2nd line of the function where `doc->editor` is dereferenced, like this:
```c static gboolean automark(gpointer user_data) { GeanyDocument *doc = (GeanyDocument *)user_data;
/* during timeout document could be destroyed so check everything again */ if (!DOC_VALID(doc)) return FALSE;
GeanyEditor *editor = doc->editor; static GeanyEditor *editor_cache = NULL; ScintillaObject *sci = editor->sci; gchar *text; static gchar text_cache[GEANY_MAX_WORD_LENGTH] = {0}; gint match_flag = SCFIND_MATCHCASE | SCFIND_WHOLEWORD; struct Sci_TextToFind ttf;
source_id = 0;
/* Do not highlight while selecting text and allow other markers to work */ if (sci_has_selection(sci)) return FALSE; ```
@codebrainz: Ahh, did oversee the initialization. Will fix it. Thanks.
Closed #574 via d079efa87f3e9ab672a3d7d6ea740f3da2e3a2b5.
github-comments@lists.geany.org