bugKawa - Bugs: bug #16313, Kawa repl in Windows keeps crashing

 
 

bug #16313: Kawa repl in Windows keeps crashing

Submitter:  None
Submitted:  Sun 09 Apr 2006 08:49:50 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Run-time exception Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 09 Feb 2007 07:34:46 AM UTC, comment #9: 

Hm.  Your patch doesn't seem right: The increment of delta is supposed to handle the case when textValueChanged is called when typing characters, and doing do in a "previous" line - i.e. before the outputMark.  In that case if we insert or remove character in a previous line, we need to adjust the outputMark.

On the other hand, spending a lot of time in these classes is probably not worthwhile.  Using a TextArea is inherently not good.  Better might be to use the Swing classes, such as as the Scheme Interaction Window of JEmacs.  Unfortunately, that also needs work.

I also have working a "command-line in a web browser", using AJAX techniques.  That works nice, but it isn't realy for general use yet.

So if your patch works for you, that's great, and hopefully we'll get something better soon.

Per Bothner <bothner>
Group administrator
Mon 05 Feb 2007 12:02:00 AM UTC, comment #8: 

OK, first I have verified that getText does not return CRLF on Windows.  Here's sample output with byte arrays output:

getText yields: 35 124 107 97 119 97 58 49 124 35 32 40 100 101 102 105 110 101 32 102 111 111 32 34 102 111 111 34 41
getText yields: 35 124 107 97 119 97 58 49 124 35 32 40 100 101 102 105 110 101 32 102 111 111 32 34 102 111 111 34 41 10 35 124 107 97 119 97 58 50 124 35 32 102 111 111
getText yields: 35 124 107 97 119 97 58 49 124 35 32 40 100 101 102 105 110 101 32 102 111 111 32 34 102 111 111 34 41 10 35 124 107 97 119 97 58 50 124 35 32 102 111 111 10 102 111 111 10 35 124 107 97 119 97 58 51 124 35 32 102 111 111

After some additional work I found a major piece of progress which seems to help.  It seems like where you had

    if (pos < outputMark)
outputMark += delta;

in the text event listener it was being called at the wrong times, because outputMark never seemed to have proper values after this part ran.  If I change it to this:

    if (pos < outputMark)
outputMark = pos;

I get things to work mostly correct.  The only problem then is that the line headers are replicated if I backtrack and re-enter a previous line.  Example:

#|kawa:1|# (define foo "Foo")
#|kawa:2|# foo
Foo
#|kawa:3|# foo
Foo
#|kawa:4|# #|kawa:3|# foo
Foo

On the last entry line, I moved the cursor back to line #|kawa:3|# and hit Enter.  It seems to work no matter where on the line I put the cursor.  So I hope this both works for you, and helps you to clear up this last issue.

Bradley Momberger <airhadoken>
Fri 02 Feb 2007 08:07:30 AM UTC, comment #7: 

Could you try to debug what is going on?

The outputMark is supposed to be the end of the output, before the user typed anything on the current line.  The normal case should be the 'pos >= outputMark' case, when you just type in last line, and only hit enter when the cursor is in that last line.  The other 'else' case is if the cursor is on one of the previous lines when you hit enter.

It may be useful to verify whether the string returned by getText() contains CRs (in addtions to LFs) on Windows.

Per Bothner <bothner>
Group administrator
Fri 02 Feb 2007 04:27:02 AM UTC, comment #6: 

I can see why Ant is a better way to compile under Windows.  I tried starting with configure & make and it took me almost 4 hours total to get everything to compile.

Unfortunately, I still got this with the latest version from SVN:

#|kawa:1|# (define foo :: <string> "Foo")
#|kawa:2|# (define bar :: <string> "Bar")
#|kawa:3|# foo
Foo
#|kawa:4|# bar#|kawa:4|# bar
Bar
#|kawa:5|# #!void#|kawa:5|# #!void
#|kawa:6|# (define baz :: <string> "Baz")#|kawa:6|# (define baz :: <string> "Baz")
#|kawa:7|#

The line is still being repeated on text entry after something is output the first time.

Bradley Momberger <airhadoken>
Thu 01 Feb 2007 06:53:19 AM UTC, comment #5: 

I'm not sure why you got into the pos < outputMark case.
However, there does seem to be some off-by-one problems.
I checked in various changes to MessageArea.java;
could you please try them?

Per Bothner <bothner>
Group administrator
Thu 01 Feb 2007 03:30:44 AM UTC, comment #4: 

Original text:
#|kawa:1|# (define foo :: <string> "foo")
#|kawa:2|# (define bar :: <string> "bar")
#|kawa:3|# bar
bar
#|kawa:4|# foo

Console output:
C:\Documents and Settings\Brad\Desktop>java -jar kawa-1.9.1.jar -w
lineBefore: 0
lineAfter: 41
Str: #|kawa:1|# (define foo :: <string> "foo")
lineBefore: 42
lineAfter: 83
Str: #|kawa:1|# (define foo :: <string> "foo")
#|kawa:2|# (define bar :: <string> "bar")
lineBefore: 84
lineAfter: 98
Str: #|kawa:1|# (define foo :: <string> "foo")
#|kawa:2|# (define bar :: <string> "bar")
#|kawa:3|# bar
lineBefore: 103
lineAfter: 117
Str: #|kawa:1|# (define foo :: <string> "foo")
#|kawa:2|# (define bar :: <string> "bar")
#|kawa:3|# bar
bar
#|kawa:4|# foo
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException
: String index out of range: 118
        at java.lang.String.substring(Unknown Source)
        at kawa.MessageArea.enter(MessageArea.java:73)
        at kawa.MessageArea.keyPressed(MessageArea.java:88)
        at java.awt.Component.processKeyEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.TextComponent.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

And finally, a scratch eval from XEmacs:

(length (append "#|kawa:1|# (define foo :: <string> \"foo\")
#|kawa:2|# (define bar :: <string> \"bar\")
#|kawa:3|# bar
bar
#|kawa:4|# foo"))
; -> 117

It seems like what is happening is that the wrong line is being found in this function.  Watch what happens when i do str = str + '\n'; before the substring call.

#|kawa:17|# (car#|kawa:17|# (car
#|(---:18|# (string->list#|(---:18|# (string->list
#|(---:19|# foo#|(---:19|# foo
#|(---:20|# )#|(---:20|# )
#|(---:21|# )#|(---:21|# )
f
#|kawa:22|#

The whole line is repeated into the buffer every time i enter text.

Bradley Momberger <airhadoken>
Wed 31 Jan 2007 08:30:22 AM UTC, comment #3: 

Can you try to debug it?   As a start insert:
  System.err.println("pos:"+pos+" lineBefore:"+lineBefore+" lineAfter:"+lineAfter+" str.len:"+str.length());
just before the failing substring operation.
Perhaps also:
  System.err.println("str: ["+str+"]");

Per Bothner <bothner>
Group administrator
Wed 31 Jan 2007 06:28:44 AM UTC, comment #2: 

I can verify that this problem happens on Windows, but only when using the graphical window.  You can get around it by only using kawa.repl in console mode.  What I see is that only the first line entered in a window correctly evaluates, and everything else gets string index out of bounds.  This leads me to believe that it has something to do with the runtime expecting CRLF for Windows output without it actually being there.

This bug has been happening for me since I started using Kawa (1.7? I guess).

Invalid User ID <#56586>
Thu 27 Apr 2006 05:08:38 AM UTC, comment #1: 

Well, I didn't get a crash.  I tried JDK 1.5.0 and gcj 4.1, both on Fedora Core 5.  It may be a problem specific to Windows, or a problem with a specific JRE that you're using.
What "java" are you using?

Per Bothner <bothner>
Group administrator
Sun 09 Apr 2006 08:49:50 PM UTC, original submission:  

After:
#|kawa:1|# (set! p (make <java.awt.Point> 3 4))
#|kawa:2|# (set! (slot-ref p 'y) 7)
#|kawa:3|# p
java.awt.Point[x=3,y=7]
#|kawa:4|#


Almost anything at the last prompt causes a crash:
(Many related sequences, after accessing java, cause the crash)

C:\Prog\Kawa>set classpath=.\kawa-1.8.jar

C:\Prog\Kawa>java kawa.repl -w
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException
: String index out of range: 134
        at java.lang.String.substring(Unknown Source)
        at kawa.MessageArea.enter(MessageArea.java:69)
        at kawa.MessageArea.keyPressed(MessageArea.java:84)
        at java.awt.Component.processKeyEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.TextComponent.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour
ce)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by airhadoken (Posted a comment)
  • -email is unavailable- added by bothner (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-02-01 bothner StatusWorks For Me Fixed
    2006-04-27 bothner StatusNone Works For Me
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code