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 73284 - Doubleclick to copy and then paste crashes terminal
Doubleclick to copy and then paste crashes terminal
Status: RESOLVED FIXED
Product: libzvt
Classification: Deprecated
Component: general
unspecified
Other Linux
: High critical
: ---
Assigned To: jacob berkman
Unknown User
: 85080 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-03-03 15:56 UTC by Mario Vukelic
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
updated patch for CVS as of 6/8 (336 bytes, patch)
2002-06-08 18:06 UTC, Samuel Stringham
none Details | Review

Description Mario Vukelic 2002-03-03 15:56:38 UTC
Here's a reproducable crash with gnome-terminal a.k.a. profterm:

Steps:
1.) Open a gnome-terminal
2.) Double-click on text in the first terminal to select a word (note: no
highlighting occurs)
3.) Middle-click-paste the copied text into the terminal (pasting into
another app that can accept middle-click-pastes

Result:
Boom

Expected:
Double-clicked text gets highlighted and pasted on middle-click

Note:
Triple-clicks work: the whole line gets highlighted and pasted on
middle-click without problems. Also, highlighting/copying by dragging works

Here's an strace:
write(2, "gnome-terminal", 14gnome-terminal)          = 14
write(2, " (pid:", 6 (pid:)                   = 6
getpid()                                = 1675
write(2, "1675", 41675)                     = 4
write(2, "): ", 3): )                      = 3
write(2, "Gdk", 3Gdk)                      = 3
write(2, "-", 1-)                        = 1
write(2, "CRITICAL **: ", 13CRITICAL **: )           = 13
write(2, "file gdkselection-x11.c: line 64"..., 93file gdkselection-x11.c:
line 640 (gdk_utf8_to_compound_text): assertion `str != NULL' failed) = 93
write(2, "\n", 1
)                       = 1
write(3, "\31\0\v\0P\0\200\1\0\0\0\0\37.\10\10gt\335\\P\0\200\1\1"..., 48) = 48
read(3, "\1\2R\2\0\0\0\0\5\0\200\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32
ioctl(3, 0x541b, [32])                  = 0
read(3, "\36\25R\2gt\335\\\36\0\0\1P\0\200\1\1\0\0\0\37\0\0\0h\1"..., 32) = 32
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8,
events=POLLIN|POLLPRI}, {fd=9, events=POLLIN|POLLPRI}, {fd=13,
events=POLLIN}, {fd=11, events=PO
LLIN}], 6, 0) = 0
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++
Comment 1 Mario Vukelic 2002-03-03 15:59:23 UTC
Ooops. In "2.) Double-click on text in the first terminal to select a
word (note: no
highlighting occurs)" please s/in the first terminal/in the terminal

Comment 2 Mario Vukelic 2002-03-03 16:04:47 UTC
Duh.

3.) Middle-click-paste the copied text into the terminal (pasting into
another app that can accept middle-click-pastes ***has the same effect)***

Comment 3 Havoc Pennington 2002-03-03 16:30:31 UTC
Can you do a backtrace?
Comment 4 Mario Vukelic 2002-03-03 16:48:40 UTC
Backtrace:

(gdb) run
[New Thread 1024 (LWP 2880)]
gnome-terminal 
gnome-terminal --window-with-profile-internal-id=Default --hide-menubar 

gnome-terminal (pid:2880): Gdk-CRITICAL **: file gdkselection-x11.c:
line 640 (gdk_utf8_to_compound_text): assertion `str != NULL' failed

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 2880)]
0x40c006df in strlen () from /lib/libc.so.6
(gdb) 


BTW, shouldn't bug-buddy catch it, too? It doesn't
Comment 5 Mario Vukelic 2002-03-03 17:03:55 UTC
I only get every 2nd comment right (hopefully). Sorry. This is what I
got out of ddd:

  • #29 __libc_start_main
    from /lib/libc.so.6
  • #28 main
    at terminal.c line 521
  • #27 gtk_main
    at gtkmain.c line 882
  • #26 g_main_loop_run
    at gmain.c line 2461
  • #25 g_main_context_iterate
    at gmain.c line 2241
  • #24 g_main_context_dispatch
    at gmain.c line 2160
  • #23 g_main_dispatch
    at gmain.c line 1616
  • #22 gdk_event_dispatch
    at gdkevents-x11.c line 1753
  • #21 gtk_main_do_event
    at gtkmain.c line 1135
  • #20 gtk_widget_event
    at gtkwidget.c line 2930
  • #19 gtk_widget_event_internal
    at gtkwidget.c line 3069
  • #18 gtk_signal_emit
    at gtksignal.c line 355
  • #17 g_signal_emit_valist
    at gsignal.c line 2109
  • #16 signal_emit_unlocked_R
    at gsignal.c line 2378
  • #15 g_closure_invoke
    at gclosure.c line 437
  • #14 g_type_class_meta_marshal
    at gclosure.c line 514
  • #13 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 82
  • #12 gtk_selection_request
    at gtkselection.c line 1116
  • #11 gtk_selection_invoke_handler
    at gtkselection.c line 1698
  • #9 g_signal_emit_valist
    at gsignal.c line 2099
  • #8 signal_emit_unlocked_R
    at gsignal.c line 2378
  • #7 g_closure_invoke
    at gclosure.c line 437
  • #6 g_type_class_meta_marshal
    at gclosure.c line 514
  • #5 _gtk_marshal_VOID__BOXED_UINT_UINT
    at gtkmarshalers.c line 1005
  • #4 zvt_term_selection_get
    at zvtterm.c line 2108
  • #3 gtk_selection_data_set_text
    at gtkselection.c line 789
  • #2 gdk_utf8_to_string_target
    at gdkselection-x11.c line 598
  • #1 sanitize_utf8
    at gdkselection-x11.c line 547
  • #0 strlen
    from /lib/libc.so.6

Comment 6 Havoc Pennington 2002-03-03 17:29:26 UTC
Zvt shouldn't be passing that NULL string to gtk_selection_data_set_text.

(Once that's fixed, should also reassign to GTK to add a
g_return_if_fail to catch that.)
Comment 7 Luis Villa 2002-03-14 19:45:29 UTC
Jacob: did this get fixed? I can no longer duplicate the crash...
Comment 8 jacob berkman 2002-03-14 20:05:35 UTC
i can reproduce it still.
Comment 9 Deepa Chacko Pillai 2002-03-28 12:11:00 UTC
I am not able to reproduce this problem. When I doubleclick a word,
it gets highlighted. On another window I am able to paste it. I could
also paste it on gedit. If this problem still exist, could you please
tell me under what conditions this is reproducible.
Comment 10 jacob berkman 2002-03-28 17:44:41 UTC
i just reproduced it again.

i think the key is for the top left part of the terminal to have
spaces instead of text.

in a terminal run 'top' then C-c

hit enter a few times until you get a line at the top of the terminal
like:

 1057 root      15   0 88508  16M  5852 S    23.2  5.1   2:42 X

and double click in the part with the space, then paste into a terminal.
Comment 11 Mario Vukelic 2002-03-28 18:49:20 UTC
I can reproduce it as Jacob just described. However, I am not entirely
sure that this is exactly the same bug as I initially experienced.  I
seem to remember that when I first reported the bug, I got the crash
everytime I doubleclicked anywhere and then pasted. However, my memory
is hazy. Anyway, if it indeed had been so, I can't reproduced it as
reported earlier
Comment 12 Deepa Chacko Pillai 2002-05-03 13:43:37 UTC
Jacob: What is the expected behaviour when you double-click on space.
Should it get highlighted? Also, when we paste the selected item,
should it give those many number of spaces? Currently, the selection
is NULL when you double-click on space. Hence, it crashes when you
paste.
Comment 13 jacob berkman 2002-05-03 17:09:30 UTC
it should to what xterm does - select the spaces.
Comment 14 Samuel Stringham 2002-05-14 15:23:38 UTC
This goes a bit deeper than just not selecting spaces.  Do we want it
to act _exactly_ as xterm?  if so then the string :
bash-2.05 $
would get broken into the words:
---------
bash
-
2
.
05
 
$
---------
instead of the behaviour now of breaking it into 
---------
bash-2.05
 
$
---------

is this expected?
Comment 15 Samuel Stringham 2002-05-14 15:31:13 UTC
this fixes the not selecting spaces.  To change the behavior of the
word selection to separate by dashes, dots, etc. it is a simple define
in zterm.c that looks like this

zvt_term_set_wordclass (ZVT_TERM (term), "-A-Za-z0-9/_:.,?+%=");

which we can change to include/not include whatever we want




--- libzvt-1.114.0/libzvt/update.c      Thu Dec  6 17:54:04 2001
+++ libzvt-1.114.0.new/libzvt/update.c  Tue May 14 11:35:34 2002
@@ -921,8 +920,6 @@
       while ((sx>0) &&
             (( (vt_in_wordclass(vx, s->data[sx])))))
        sx--;
-      if (!vt_in_wordclass(vx, s->data[sx]))
-       sx++;
     }
     d(printf("%d\n", sx));
 
Comment 16 Samuel Stringham 2002-05-14 18:20:22 UTC
okay, I lied, this patch fixes one problem, but reopens a different
bug (can't remember the number) that has to do with appending
extraneous characters.  Will look into more.
Comment 17 Samuel Stringham 2002-05-14 18:22:35 UTC
nope, wrong again, after investigating more, that patch fixes this
bug, will open a different one for bug I am experiencing. (double
click pastes three copies of text, not two)
Comment 18 Samuel Stringham 2002-05-21 06:51:02 UTC
patch below makes it so libzvt selects at least one character.  Filing
a different bug for full xterm compatability.

--- libzvt-1.115.2/libzvt/update.c      Thu Dec  6 17:54:04 2001
+++ libzvt-1.115.2.new/libzvt/update.c  Tue May 21 02:56:33 2002
@@ -935,7 +935,8 @@
         while ((ex<e->width) && 
             ( (vt_in_wordclass(vx, e->data[ex]))))
        ex++;
-
+    if (ex == sx) 
+        sx--;
     break;
   case VT_SELTYPE_CHAR:
   default:
Comment 19 Luis Villa 2002-05-24 21:57:13 UTC
Jacob: what is the situation with this bug? I know it isn't yours, but
does this patch fix the situation? If so, can you apply?
Comment 20 jacob berkman 2002-05-28 19:40:45 UTC
this patch is bogus.

i think the correct solution is to check if sx == ex && sy == ey, then
scan fwd. back for "blank" characters
Comment 21 Samuel Stringham 2002-05-29 17:46:55 UTC
sy == ey doesn't make a difference right now as we do not do line
wrapping selects on words.  Also scanning forward will result in the
wrong(?) character getting selected e.g. in " &" if you double click
the space then the & sign will get selected if you increment the
pointer.  Maybe I misunderstoood, or maybe that is what is wanted.
Comment 22 arunapr 2002-06-03 04:16:33 UTC
the same thing is observed with all the chars which are not there in 
list of "Select-by-word characters" in the profile. As for my 
understanding the chars which are not in this set will act as 
seprator. Here the space/tab has to considered as special case
Comment 23 Luis Villa 2002-06-06 05:08:54 UTC
Hrm... so can someone update me on the status of this one? I'd
/really/ like to see a fix for this in the Release Candidate.
Comment 24 Bharat Tewari 2002-06-06 07:39:46 UTC
not too sure whether this is the 100% correct solution but i tested
out on my machine and this patch seems to fix atleast the crash
issues. Whether it should be returning NULL or not in zvttermc:2183 is
somebody who knows utf stuff. This is inline with havoc's comment. To
explain it further, second parameter passed to
gtk_selection_set_data_text() is 0x0 and down below its never checked
for NULL at all and during strlen() zvt dumps core. Now before passing
it to gtk_selection_set_data_text() check if its Non-null.

Index: libzvt/libzvt/zvtterm.c
===================================================================
RCS file: /export/cvs/gnome-2.0/libzvt/libzvt/zvtterm.c,v
retrieving revision 1.6
diff -p -u -5 -r1.6 zvtterm.c
--- libzvt/libzvt/zvtterm.c     2002/06/03 21:27:06     1.6
+++ libzvt/libzvt/zvtterm.c     2002/06/06 07:27:18
@@ -2179,10 +2179,12 @@ zvt_term_selection_get (GtkWidget

   term = ZVT_TERM (widget);
   vx = term->vx;

   converted = zvt_term_convert_selection (term, info, &len);
+  g_return_if_fail (converted != NULL);
+
   gtk_selection_data_set_text (selection_data_ptr, converted, len);
   g_free(converted);
 }

 /**
Comment 25 Samuel Stringham 2002-06-06 14:47:51 UTC
This just makes it so you can't cut/paste spaces (or any other 
special, nonword character).  I don't think this is the 'correct' 
fix.  I think the patch I had above should be something more along 
the correct line, and Bharat's patch as well, just for some double 
checking.  Anyone with more input as to what the correct way is?  Do 
we want it to select all contiguous spaces?  all contiguous non-word 
characters?  I don't know what is wanted here.
Comment 26 jacob berkman 2002-06-06 15:17:16 UTC
bharat's latest patch doesn't fix anying.

in fact, in optimized builds g_return_* statements aren't even
compiled in.

the desired behaviour is to do what xterm does - i think it just
selects tabs / spaces
Comment 27 Bharat Tewari 2002-06-07 04:08:49 UTC
oh sorry about it, though i was more worried about the terminal crash
rather than the functionality implementation. Jacob will it be okay to
have a hack/fixme which just checks whether the converted is NULL and
if it is, just return from the function. I know thats not a solution
but if we go for the 2.0.0 release and luis finds this as a blocker
bug, atleast the crash will be prevented.
Comment 28 Samuel Stringham 2002-06-07 14:19:42 UTC
Like Jacob said, that g_return statement won't even get compiled in. 
If we are just looking for stopping the crash, and fixing full xterm
emulation in 2.x or so just apply my patch above (with some offset
probably).  Also as Jacob said before you should add in a check for sy
== ey just in case bug 80950 gets fixed.
Comment 29 Samuel Stringham 2002-06-08 18:06:59 UTC
Created attachment 9077 [details] [review]
updated patch for CVS as of 6/8
Comment 30 Samuel Stringham 2002-06-08 18:08:41 UTC
above patch does not fix the problem completely to the point of xterm
compliance, but it is a workaround that will make it so the terminal
won't crash.  As 2.0.0 is approaching maybe we should push xterm
cut/paste compliance to 2.0.1.
Comment 31 Luis Villa 2002-06-08 18:28:16 UTC
Yeah. All I want (all I'd accept as a release team member ATM, even,
given the possibility of other things breaking in gnome-terminal) is
it not to crash :) Jacob?
Comment 32 jacob berkman 2002-06-10 17:08:20 UTC
can sx be 0 before you decrement it?

what happens in this case?
Comment 33 Samuel Stringham 2002-06-10 21:33:07 UTC
sx cannot be 0 at that point, no.  sx always starts on the right hand
side of the selection and goes to the left.
Comment 34 jacob berkman 2002-06-10 21:49:20 UTC
are you sure?

  /* range check horizontal */
  if (vx->selstartx<0)
    vx->selstartx=0;

...

     sx = vx->selstartx;      

...

etc?

or am i reading things wrong (that code is not easy to understand)
Comment 35 Samuel Stringham 2002-06-10 23:42:44 UTC
gdk_window_get_pointer should (key word) always returns >0 so that
shouldn't happen.  Even when sx does = 0 and gets decremented to -1
the selection still goes from -1 to 1 and highlights/cuts/pastes just
the first word on the line (or first character if it is special).  So
I don't see any new bugs popping up with the introduction of this
code.  I vow I will clean this up some more later:)
Comment 36 jacob berkman 2002-06-11 15:46:46 UTC
ok, the patch will be committed shortly.

we'll see how it does ;)
Comment 37 Samuel Stringham 2002-06-30 07:00:51 UTC
*** Bug 85080 has been marked as a duplicate of this bug. ***