www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - Pasting illegal character causes segmentation fault

reply Mitja <mitja_ursic yahoo.com> writes:
When I paste illegal character (looks like rectangle) in Text widget,
application exits with segmentation fault. I cannot catch bad character with
Verify Listener, because it's already too late. Is there any other way to
detect it?

Platform is Debian 5.0.3 (lenny), DMD v1.033.
Dec 25 2009
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
Am 25.12.2009 13:22, schrieb Mitja:
 When I paste illegal character (looks like rectangle) in Text widget,
 application exits with segmentation fault. I cannot catch bad character with
Verify Listener, because it's already too late. Is there any other way to
detect it?
 
 Platform is Debian 5.0.3 (lenny), DMD v1.033.
Can you give a stack trace, the exact character you pasted and perhaps a compilable small example code to reproduce the bug?
Dec 25 2009
parent reply Mitja <mitja_ursic yahoo.com> writes:
strace output:
select(4, [3], [3], NULL, NULL)         = 1 (out [3])
writev(3, [{"\24\0\6\0005\2 \5\343\2\0\0\0\0\0\0\0\0\0\0\377\377\377\37"...,
24}], 1) = 24
select(4, [3], [], NULL, NULL)          = 1 (in [3])
read(3, "\1\10S6\4\0\0\0006\1\0\0\0\0\0\0\17\0\0\0VJ\25\10\374\325
\10tc\346\277\203"..., 4096) = 48
read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
select(4, [3], [3], NULL, NULL)         = 1 (out [3])
writev(3, [{"+\0\1\0"..., 4}], 1)       = 4
select(4, [3], [], NULL, NULL)          = 1 (in [3])

\10tc\346\277x+\177\td\"\36\10Y3\t\10"..., 4096) = 32
read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
select(4, [3], [3], NULL, NULL)         = 1 (out [3])
writev(3, [{"\23\0\3\0005\2 \5\343\2\0\0+\0\1\0"..., 16}], 1) = 16
select(4, [3], [], NULL, NULL)          = 1 (in [3])
read(3, "\34\"U65\2 \5\343\2\0\0\0\252Fc\1\2\0\0\4\0\0\0\1\0\0\0 B\233\t\1"...,
4096) = 64
read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
--- SIGSEGV (Segmentation fault)   0 (0) ---
+++ killed by SIGSEGV +++

Example code:
module text;

import dwt.DWT;
import dwt.custom.StyleRange;
import dwt.widgets.Text;
import dwt.layout.FillLayout;
import dwt.widgets.Display;
import dwt.widgets.Shell;

void main() {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Text text = new Text(shell, DWT.BORDER);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
}

I cannot reproduce the character.
The way I got it was by pasting block of Japanese or Chinese characters into
text widget and then selecting by mouse and copying a few characters from that
block.
Illegal character(s) would as a result of copying appear in Klipper (KDE
clipboard), usually in front or at the end of copied selection.
Segmentation fault would occur when I pasted back the very same selection, now
with prepended or appended illegal characters.


Frank Benoit Wrote:

 Am 25.12.2009 13:22, schrieb Mitja:
 When I paste illegal character (looks like rectangle) in Text widget,
 application exits with segmentation fault. I cannot catch bad character with
Verify Listener, because it's already too late. Is there any other way to
detect it?
 
 Platform is Debian 5.0.3 (lenny), DMD v1.033.
Can you give a stack trace, the exact character you pasted and perhaps a compilable small example code to reproduce the bug?
Dec 25 2009
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
Am 25.12.2009 23:26, schrieb Mitja:
 strace output:
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"\24\0\6\0005\2 \5\343\2\0\0\0\0\0\0\0\0\0\0\377\377\377\37"...,
24}], 1) = 24
 select(4, [3], [], NULL, NULL)          = 1 (in [3])
 read(3, "\1\10S6\4\0\0\0006\1\0\0\0\0\0\0\17\0\0\0VJ\25\10\374\325
\10tc\346\277\203"..., 4096) = 48
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"+\0\1\0"..., 4}], 1)       = 4
 select(4, [3], [], NULL, NULL)          = 1 (in [3])

\10tc\346\277x+\177\td\"\36\10Y3\t\10"..., 4096) = 32
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"\23\0\3\0005\2 \5\343\2\0\0+\0\1\0"..., 16}], 1) = 16
 select(4, [3], [], NULL, NULL)          = 1 (in [3])
 read(3, "\34\"U65\2 \5\343\2\0\0\0\252Fc\1\2\0\0\4\0\0\0\1\
\0\0 B\233\t\1"..., 4096) = 64
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 --- SIGSEGV (Segmentation fault)   0 (0) ---
 +++ killed by SIGSEGV +++
 
Oh, i did not mean strace (which is a trace of the OS calls a process does), instead i mean stack trace. You can perhaps get it with the current tango (i think) or by running the program in GDC and after the segfault run the "backtrace" command in it. It show the code line where the segfault happens and the code lines where this one was called from.
 Example code:
 module text;
 
 import dwt.DWT;
 import dwt.custom.StyleRange;
 import dwt.widgets.Text;
 import dwt.layout.FillLayout;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
 
 void main() {
     Display display = new Display();
     Shell shell = new Shell(display);
     shell.setLayout(new FillLayout());
     Text text = new Text(shell, DWT.BORDER);
     shell.pack();
     shell.open();
     while (!shell.isDisposed()) {
       if (!display.readAndDispatch())
         display.sleep();
     }
     display.dispose();
 }
 
thanks.
 I cannot reproduce the character.
 The way I got it was by pasting block of Japanese or Chinese characters into
text widget and then selecting by mouse and copying a few characters from that
block.
 Illegal character(s) would as a result of copying appear in Klipper (KDE
clipboard), usually in front or at the end of copied selection.
 Segmentation fault would occur when I pasted back the very same selection, now
with prepended or appended illegal characters.
 
Hm, perhaps you can paste the same into a editor and open it with a hex-view (hexdump) to make the byte values visible.
Dec 25 2009
parent reply Mitja <mitja_ursic yahoo.com> writes:
gdb backtrace:
(gdb) run
Starting program:
[Thread debugging using libthread_db enabled]
[New Thread 0xb74fd6b0 (LWP 5486)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb74fd6b0 (LWP 5486)]
0x080a1458 in _D3dwt8graphics6Device6Device11logFunctionUPaiPaPvZv ()
Current language:  auto; currently asm
(gdb) backtrace


log_level=G_LOG_LEVEL_WARNING,
    format=0xb7c5b58c "Error converting selection from UTF8_STRING",



log_level=G_LOG_LEVEL_WARNING, format=0xb7c5b58c "Error converting selection
from UTF8_STRING")
    at gmessages.c:517

optimized out>, latin1=0, list=0xbf971364) at gdkselection-x11.c:523

(display=0xa165020, encoding=0x4a, format=8,



at gtkselection.c:1431

selection_data=0xbf971870, data=0xa2271a0) at gtkclipboard.c:911

selection_data=0xbf971870, time=1699038784) at gtkclipboard.c:847

return_value=0x0, n_param_values=3, param_values=0xbf971618,
    invocation_hint=0xbf971528, marshal_data=0xb7af6310) at gtkmarshalers.c:1584

n_param_values=3, param_values=0xbf971618, invocation_hint=0xbf971528)
    at gclosure.c:490

instance=0xa1e02e8, emission_return=0x0, instance_and_params=0xbf971618)
    at gsignal.c:2440

detail=0, var_args=0xbf97186c "\200]\"\nE") at gsignal.c:2199

detailed_signal=0xb7bae9df "selection_received") at gsignal.c:2267

optimized out>, format=<value optimized out>,
    buffer=0xa2281f8

length=12, time=1699038784) at gtkselection.c:2772

gtkselection.c:2578

return_value=0xbf971a5c, n_param_values=2, param_values=0xbf971b38,
    invocation_hint=0xbf971a48, marshal_data=0xb7a20220) at gtkmarshalers.c:84

return_value=0xbf971a5c, n_param_values=2, param_values=0xbf971b38,
    invocation_hint=0xbf971a48, marshal_data=0xfc) at gclosure.c:567

return_value=0xbf971a5c, n_param_values=2, param_values=0xbf971b38,
invocation_hint=0xbf971a48)
    at gclosure.c:490

instance=0xa1e02e8, emission_return=0xbf971cf8, instance_and_params=0xbf971b38)
    at gsignal.c:2478

detail=0,
    var_args=0xbf971d7c

002\036\nH)\027\n") at gsignal.c:2209

detail=0) at gsignal.c:2243

at gtkwidget.c:4678


l1c3gdk9_GdkEventZv ()

l1c3gdk9_GdkEventZv ()

c3gdk9_GdkEventPvZv ()

user_data=0x0) at gdkevents-x11.c:2351

gmain.c:2012

dispatch=1, self=0xa14b8e0) at gmain.c:2645

at gmain.c:2708

ext_iterationFPviZi ()






---Type <return> to continue, or q <return> to quit--- 

After more fiddling around with this, I think only copying from
StyledText widget to clipboard appends illegal characters, not from standard
Text widget.

There appear to be at least 7 different questionable characters.

Emacs' representation of illegal characters:




Hex dump:
00000000: beb4 20e3 8388 e383 a2e3 8387 e383 ab20  .. ............
00000010: e30a 81a8 e382 bbe3 839e e383 b3e3 8386  ................
00000020: e382 a30a 839e e383 b3e3 8386 e382 a3e3  ................

Actual text:





Frank Benoit Wrote:

 Am 25.12.2009 23:26, schrieb Mitja:
 strace output:
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"\24\0\6\0005\2 \5\343\2\0\0\0\0\0\0\0\0\0\0\377\377\377\37"...,
24}], 1) = 24
 select(4, [3], [], NULL, NULL)          = 1 (in [3])
 read(3, "\1\10S6\4\0\0\0006\1\0\0\0\0\0\0\17\0\0\0VJ\25\10\374\325
\10tc\346\277\203"..., 4096) = 48
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"+\0\1\0"..., 4}], 1)       = 4
 select(4, [3], [], NULL, NULL)          = 1 (in [3])

\10tc\346\277x+\177\td\"\36\10Y3\t\10"..., 4096) = 32
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 select(4, [3], [3], NULL, NULL)         = 1 (out [3])
 writev(3, [{"\23\0\3\0005\2 \5\343\2\0\0+\0\1\0"..., 16}], 1) = 16
 select(4, [3], [], NULL, NULL)          = 1 (in [3])
 read(3, "\34\"U65\2 \5\343\2\0\0\0\252Fc\1\2\0\0\4\0\0\0\1\
\0\0 B\233\t\1"..., 4096) = 64
 read(3, 0x840a2fc, 4096)                = -1 EAGAIN (Resource temporarily
unavailable)
 --- SIGSEGV (Segmentation fault)   0 (0) ---
 +++ killed by SIGSEGV +++
 
Oh, i did not mean strace (which is a trace of the OS calls a process does), instead i mean stack trace. You can perhaps get it with the current tango (i think) or by running the program in GDC and after the segfault run the "backtrace" command in it. It show the code line where the segfault happens and the code lines where this one was called from.
 Example code:
 module text;
 
 import dwt.DWT;
 import dwt.custom.StyleRange;
 import dwt.widgets.Text;
 import dwt.layout.FillLayout;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
 
 void main() {
     Display display = new Display();
     Shell shell = new Shell(display);
     shell.setLayout(new FillLayout());
     Text text = new Text(shell, DWT.BORDER);
     shell.pack();
     shell.open();
     while (!shell.isDisposed()) {
       if (!display.readAndDispatch())
         display.sleep();
     }
     display.dispose();
 }
 
thanks.
 I cannot reproduce the character.
 The way I got it was by pasting block of Japanese or Chinese characters into
text widget and then selecting by mouse and copying a few characters from that
block.
 Illegal character(s) would as a result of copying appear in Klipper (KDE
clipboard), usually in front or at the end of copied selection.
 Segmentation fault would occur when I pasted back the very same selection, now
with prepended or appended illegal characters.
 
Hm, perhaps you can paste the same into a editor and open it with a hex-view (hexdump) to make the byte values visible.
Dec 25 2009
parent Frank Benoit <keinfarbton googlemail.com> writes:
sorry, i thought i can take the time.
but i haven't, so i can get you the support and fix the problem.

I someone else willing to fix that?
Dec 26 2009