After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 605881 - Crash when hitting enter key or deleting lines of code in Anjuta
Crash when hitting enter key or deleting lines of code in Anjuta
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
git master
Other Linux
: Normal critical
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
: 611201 (view as bug list)
Depends on:
Blocks: 610394
 
 
Reported: 2010-01-02 04:22 UTC by James Liggett
Modified: 2010-02-28 19:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Put a boundary check for document end. (1.27 KB, patch)
2010-02-17 20:14 UTC, Naba Kumar
none Details | Review
Word completion crasher fix (32.07 KB, patch)
2010-02-28 18:05 UTC, jessevdk@gmail.com
committed Details | Review

Description James Liggett 2010-01-02 04:22:08 UTC
Every so often, when I either create a new line by hitting the Enter key, or when I delete a line of code in Anjuta, it crashes in GtkSourceView:

Program received signal SIGSEGV, Segmentation fault.
0x0279ac2d in idle_scan_regions (buffer=0x996ec10)
    at gtksourcecompletionwordsbuffer.c:287
287				remove_line ((GList *)ptr->data, buffer);
(gdb) bt
  • #0 idle_scan_regions
    at gtksourcecompletionwordsbuffer.c line 287
  • #1 ??
    from /lib/libglib-2.0.so.0
  • #2 g_main_context_dispatch
    from /lib/libglib-2.0.so.0
  • #3 ??
    from /lib/libglib-2.0.so.0
  • #4 g_main_loop_run
    from /lib/libglib-2.0.so.0
  • #5 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #6 main
    at main.c line 248

Comment 1 jessevdk@gmail.com 2010-01-02 11:17:52 UTC
Just to be sure, you are using the latest 'master' of gtksourceview. There have been some changes recently concerning this kind of bug (see 2e5428c0).
Comment 2 Johannes Schmid 2010-01-02 11:33:46 UTC
I have experienced the same but I didn't check with the latest trunk version. Anyway, a work-around in anjuta for now is to disabled autocompletion of words in the sourceview preferences (language assistance will still work).
Comment 3 James Liggett 2010-01-02 21:08:59 UTC
(In reply to comment #1)
> Just to be sure, you are using the latest 'master' of gtksourceview. There have
> been some changes recently concerning this kind of bug (see 2e5428c0).

Pulled from git and recompiled today; it crashed as I was typing.
Comment 4 jessevdk@gmail.com 2010-01-03 12:05:57 UTC
I can't easily reproduce this with gedit or test-completion in the gtksourceview repository. Are there any settings for the word-completion provider that are not the default? Or anything in the use of GtkSourceCompletion in Anjuta that might trigger this bug in the word completion provider?
Comment 5 jessevdk@gmail.com 2010-01-03 13:52:00 UTC
I just compiled anjuta 2.29.4 but also can't seem to be able to reproduce. Is there an easy way of triggering this, or does it just occasionally happen?
Comment 6 James Liggett 2010-01-09 07:02:21 UTC
Well, the only way I caught the backtrace I got was to run anjuta under gdb, and then just hack like usual until it crashed.

Sorry I can't come up with a better recipie :(
Comment 7 Paolo Borelli 2010-01-30 10:44:44 UTC
James: does this still happen?
Comment 8 Naba Kumar 2010-02-17 20:12:30 UTC
Happened with me as well. And when I filed a new bug, I came across this one :). It's with "master". Here is a patch as well.

The bug: in Anjuta, where word completion is enabled, gtksouceview crashes when pressing enter in last line of document. There happens a NULL pointer dereference at gtksourcecompletionwordsbuffer.c:287.

(gdb) run
Starting program: /usr/local/bin/anjuta 
[Thread debugging using libthread_db enabled]
[New Thread 0xb7820b70 (LWP 3376)]
[New Thread 0xb701eb70 (LWP 3379)]
[New Thread 0xb5ac7b70 (LWP 3408)]
[New Thread 0xb5028b70 (LWP 3413)]
[Thread 0xb5028b70 (LWP 3413) exited]
[Thread 0xb7820b70 (LWP 3376) exited]
[New Thread 0xb7820b70 (LWP 3416)]
[New Thread 0xb5028b70 (LWP 3424)]
[New Thread 0xb46ffb70 (LWP 3425)]
[New Thread 0xb3efeb70 (LWP 3426)]
[Thread 0xb7820b70 (LWP 3416) exited]
[Thread 0xb3efeb70 (LWP 3426) exited]
[Thread 0xb5028b70 (LWP 3424) exited]
[New Thread 0xb5028b70 (LWP 3440)]
[New Thread 0xb3efeb70 (LWP 3441)]
[New Thread 0xb7820b70 (LWP 3442)]
[Thread 0xb3efeb70 (LWP 3441) exited]
[Thread 0xb7820b70 (LWP 3442) exited]
[Thread 0xb46ffb70 (LWP 3425) exited]
[New Thread 0xb46ffb70 (LWP 3445)]
[New Thread 0xb7820b70 (LWP 3446)]
[New Thread 0xb3efeb70 (LWP 3447)]
[Thread 0xb7820b70 (LWP 3446) exited]
[Thread 0xb46ffb70 (LWP 3445) exited]
[Thread 0xb3efeb70 (LWP 3447) exited]
[Thread 0xb5028b70 (LWP 3440) exited]

Program received signal SIGSEGV, Segmentation fault.
0x03db63ad in idle_scan_regions (buffer=0x8fefb88)
    at gtksourcecompletionwordsbuffer.c:287
287				remove_line ((GList *)ptr->data, buffer);
(gdb) bt
  • #0 idle_scan_regions
    at gtksourcecompletionwordsbuffer.c line 287
  • #1 ??
    from /lib/libglib-2.0.so.0
  • #2 g_main_context_dispatch
    from /lib/libglib-2.0.so.0
  • #3 ??
    from /lib/libglib-2.0.so.0
  • #4 g_main_loop_run
    from /lib/libglib-2.0.so.0
  • #5 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #6 main
    at main.c line 248
282			ptr = g_list_nth (ptr, region->start - prev);
283			
284			for (i = 0; i < doscan; ++i)
285			{
286				/* First remove this line */
287				remove_line ((GList *)ptr->data, buffer);
288				
289				/* Then scan it which adds words */
290				ptr->data = scan_line (buffer, region->start + i);
291	
(gdb) print ptr
$1 = (GList *) 0x0
(gdb) print *region
$4 = {start = 535, end = 535}
(gdb) print g_list_length (buffer->priv->lines)
$7 = 535
(gdb) print i
$8 = 0

At a glance, the reason seems to be that the scan loop goes beyond document boundary. I am not sure if the loop is supposed to be somehow aligned with document end, but it doesn't seem to. Here is a patch that breaks the loop when reaching the boundary in any case.
Comment 9 Naba Kumar 2010-02-17 20:14:08 UTC
Created attachment 154077 [details] [review]
Put a boundary check for document end.
Comment 10 jessevdk@gmail.com 2010-02-20 10:28:42 UTC
The patch fixes the problem, but as you said, the scanning should be aligned with the end of the document. This probably means that the region stack is corrupt at the time of the crash.
Comment 11 Johannes Schmid 2010-02-20 11:09:13 UTC
How could the region stack be currupt? General memory corruption of something wrong in GtkTextView/GtkSourceView?

I would really apreciate if this patch could be applied because otherwise I guess we would have to disable the "Word" provider entirely in anjuta because it's just crashing far too often.
Comment 12 jessevdk@gmail.com 2010-02-20 11:24:24 UTC
The problem is definitely in the words completion. It should keep the stack of scan regions in sync with the changes in the buffer. The rest of the code (in particular where the crash happens) assumes it can trust the scan regions to be valid. What I mean was that the crash indicates that there is a problem in keeping the scan regions correct. Fixing it like with the patch is not correct because the scan regions will still be wrong (and might break other places).

I will have a look at the problem today. If I can't find the problem in time, we can still apply this patch as a temporary measure to at least not have it crash. But I want to find the real cause.
Comment 13 Johannes Schmid 2010-02-27 12:00:53 UTC
*** Bug 611201 has been marked as a duplicate of this bug. ***
Comment 14 jessevdk@gmail.com 2010-02-28 18:05:23 UTC
Created attachment 154904 [details] [review]
Word completion crasher fix

This patch should fix the issues with the word completion. Basicly changed the whole approach because the previous one was not going to work with the way insert-text/delete-range works. The proposed patch uses marks instead to mark regions in the buffer that need to be scanned. It keeps the doc in sync with the library by scanning words also when they need to be removed, and keeping a hash table to the proposals.
Comment 15 jessevdk@gmail.com 2010-02-28 19:50:07 UTC
I went ahead and committed the patch, together with some small improvements to the performance hit when you load large documents.