Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328015

Summary: Crash when typing in Persian using onscreen keyboard
Product: [Eclipse Project] Platform Reporter: Babak Taraghi <babak.taraghi>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: CLOSED INVALID QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: critical    
Priority: P3 CC: babak.taraghi, eclipse.felipe, jacek.pospychala, skovatch
Version: 3.6   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard: stalebug
Attachments:
Description Flags
Test case none

Description Babak Taraghi CLA 2010-10-18 04:39:04 EDT
Build Identifier: 20100617-1415

This error was generated by mac to report to apple, hope this will help.

Process:         eclipse [293]
Path:            /Applications/eclipse-helios/Eclipse.app/Contents/MacOS/eclipse
Identifier:      org.eclipse.eclipse
Version:         3.6 (3.6)
Code Type:       X86-64 (Native)
Parent Process:  launchd [234]

Date/Time:       2010-10-18 11:51:12.682 +0330
OS Version:      Mac OS X 10.6.4 (10F569)
Report Version:  6

Model: MacBookAir2,1, BootROM MBA21.0075.B03, 2 processors, Intel Core 2 Duo, 2.13 GHz, 2 GB, SMC 1.34f8
Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x90), Broadcom BCM43xx 1.0 (5.10.91.27)
Bluetooth: Version 2.3.3f8, 2 service, 12 devices, 1 incoming serial ports
Network Service: USB Ethernet, Ethernet, en2
Network Service: USB Ethernet, Ethernet, en2
Serial ATA Device: APPLE SSD SM128, 113 GB
USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8505, 0x24400000
USB Device: Apple USB Ethernet Adapter, 0x05ac  (Apple Inc.), 0x1402, 0x24100000
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0223, 0x04600000
USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x04500000
USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x06100000
USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8216, 0x06110000

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000001949127658
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:

Java information:
 Exception type: Bus Error (0xa) at pc=7fffffe007c5

 Java VM: Java HotSpot(TM) 64-Bit Server VM (16.3-b01-279 mixed mode macosx-amd64)

Current thread (113001000):  JavaThread "main" [_thread_in_native, id=1896107040, stack(7fff5f400000,7fff5fc00000)]
Stack: [7fff5f400000,7fff5fc00000]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.eclipse.swt.internal.cocoa.OS.objc_msgSend_stret(Lorg/eclipse/swt/internal/cocoa/NSRange;JJJ)V+0
j  org.eclipse.swt.internal.cocoa.NSLayoutManager.glyphRangeForTextContainer(Lorg/eclipse/swt/internal/cocoa/NSTextContainer;)Lorg/eclipse/swt/internal/cocoa/NSRange;+28
j  org.eclipse.swt.graphics.TextLayout.computeRuns()V+1492
J  org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(IIII)Lorg/eclipse/swt/graphics/TextLayout;
j  org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(I)Lorg/eclipse/swt/graphics/TextLayout;+23
j  org.eclipse.swt.custom.StyledTextRenderer.calculate(II)V+74
j  org.eclipse.swt.custom.StyledTextRenderer.calculateClientArea()V+38
j  org.eclipse.swt.custom.StyledText.resetCache(II)V+21
j  org.eclipse.swt.custom.StyledText.handleTextChanged(Lorg/eclipse/swt/custom/TextChangedEvent;)V+56
j  org.eclipse.swt.custom.StyledText$6.textChanged(Lorg/eclipse/swt/custom/TextChangedEvent;)V+5
j  org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter$5.run()V+33
j  org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter.runOnDisplayThreadIfNeedede(Ljava/lang/Runnable;)V+21
j  org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter.relayTextChanged()V+29
j  org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter$DocumentListener.documentChanged(Lorg/eclipse/jface/text/DocumentEvent;)V+47
j  org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireDocumentChanged([Ljava/lang/Object;Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;)V+49
j  org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(Lorg/eclipse/wst/sse/core/internal/provisional/events/RegionChangedEvent;)V+24
j  org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(Ljava/lang/Object;IILjava/lang/String;JZ)Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;+231
j  org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(Ljava/lang/Object;IILjava/lang/String;JZ)Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;+10
j  org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(Ljava/lang/Object;IILjava/lang/String;)Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;+43
j  org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.access$2(Lorg/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument;Ljava/lang/Object;IILjava/lang/String;)Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;+6
j  org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument$3.run()V+25
j  org.eclipse.core.runtime.SafeRunner.run(Lorg/eclipse/core/runtime/ISafeRunnable;)V+5
j  org.eclipse.wst.sse.ui.EditorExecutionContext.execute(Lorg/eclipse/core/runtime/ISafeRunnable;)V+25
j  org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(Ljava/lang/Object;IILjava/lang/String;)Lorg/eclipse/wst/sse/core/internal/provisional/events/StructuredDocumentEvent;+55
j  org.eclipse.wst.sse.ui.internal.StructuredDocumentToTextAdapter.replaceTextRange(IILjava/lang/String;)V+53
j  org.eclipse.swt.custom.StyledText.modifyContent(Lorg/eclipse/swt/widgets/Event;Z)V+276
j  org.eclipse.swt.custom.StyledText.sendKeyEvent(Lorg/eclipse/swt/widgets/Event;)V+10
j  org.eclipse.swt.custom.StyledText.doContent(C)V+257
j  org.eclipse.swt.custom.StyledText.handleKey(Lorg/eclipse/swt/widgets/Event;)V+270
j  org.eclipse.swt.custom.StyledText.handleKeyDown(Lorg/eclipse/swt/widgets/Event;)V+153
j  org.eclipse.swt.custom.StyledText$7.handleEvent(Lorg/eclipse/swt/widgets/Event;)V+104
J  org.eclipse.swt.widgets.EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)V
j  org.eclipse.swt.widgets.Display.sendEvent(Lorg/eclipse/swt/widgets/EventTable;Lorg/eclipse/swt/widgets/Event;)V+24
j  org.eclipse.swt.widgets.Widget.sendEvent(Lorg/eclipse/swt/widgets/Event;)V+9
j  org.eclipse.swt.widgets.Widget.sendEvent(ILorg/eclipse/swt/widgets/Event;Z)V+73
j  org.eclipse.swt.widgets.Widget.sendEvent(ILorg/eclipse/swt/widgets/Event;)V+4
j  org.eclipse.swt.widgets.Widget.sendKeyEvent(ILorg/eclipse/swt/widgets/Event;)Z+3
j  org.eclipse.swt.widgets.Control.insertText(JJJ)Z+176
j  org.eclipse.swt.widgets.Canvas.insertText(JJJ)Z+28
J  org.eclipse.swt.widgets.Display.windowProc(JJJ)J
v  ~StubRoutines::call_stub
J  org.eclipse.swt.internal.cocoa.OS.objc_msgSend(JJJ)J
j  org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(Lorg/eclipse/swt/internal/cocoa/NSArray;)V+19
j  org.eclipse.swt.widgets.Composite.keyDown(JJJ)V+53
J  org.eclipse.swt.widgets.Display.windowProc(JJJ)J
v  ~StubRoutines::call_stub
J  org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Lorg/eclipse/swt/internal/cocoa/objc_super;JJ)J
j  org.eclipse.swt.widgets.Widget.callSuper(JJJ)V+32
j  org.eclipse.swt.widgets.Widget.windowSendEvent(JJJ)V+5
j  org.eclipse.swt.widgets.Shell.windowSendEvent(JJJ)V+422
J  org.eclipse.swt.widgets.Display.windowProc(JJJ)J
v  ~StubRoutines::call_stub
J  org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Lorg/eclipse/swt/internal/cocoa/objc_super;JJ)J
j  org.eclipse.swt.widgets.Display.applicationSendEvent(JJJ)V+383
j  org.eclipse.swt.widgets.Display.applicationProc(JJJ)J+67
v  ~StubRoutines::call_stub
J  org.eclipse.swt.internal.cocoa.OS.objc_msgSend(JJJ)J
j  org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(Lorg/eclipse/swt/internal/cocoa/NSEvent;)V+19
j  org.eclipse.swt.widgets.Display.readAndDispatch()Z+113
j  org.eclipse.ui.internal.Workbench.runEventLoop(Lorg/eclipse/jface/window/Window$IExceptionHandler;Lorg/eclipse/swt/widgets/Display;)V+9
j  org.eclipse.ui.internal.Workbench.runUI()I+555
j  org.eclipse.ui.internal.Workbench.access$4(Lorg/eclipse/ui/internal/Workbench;)I+1
j  org.eclipse.ui.internal.Workbench$7.run()V+55
j  org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
j  org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+18
j  org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j  org.eclipse.ui.internal.ide.application.IDEApplication.start(Lorg/eclipse/equinox/app/IApplicationContext;)Ljava/lang/Object;+99
j  org.eclipse.equinox.internal.app.EclipseAppHandle.run(Ljava/lang/Object;)Ljava/lang/Object;+135
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ljava/lang/Object;)Ljava/lang/Object;+103
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ljava/lang/Object;)Ljava/lang/Object;+29
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+149
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+183
v  ~StubRoutines::call_stub
j  sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j  sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j  org.eclipse.equinox.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+211
j  org.eclipse.equinox.launcher.Main.basicRun([Ljava/lang/String;)V+126
j  org.eclipse.equinox.launcher.Main.run([Ljava/lang/String;)I+4
v  ~StubRoutines::call_stub


Reproducible: Always

Steps to Reproduce:
1.Change the system language to Persian
2.Open on screen keyboard
3.Open a language file
4.start typing something
BomB
Comment 1 Jacek Pospychala CLA 2010-10-18 05:11:09 EDT
Moving to SWT team
Comment 2 Scott Kovatch CLA 2010-10-18 14:05:19 EDT
(In reply to comment #0)
> Steps to Reproduce:
> 1.Change the system language to Persian
> 2.Open on screen keyboard
> 3.Open a language file
> 4.start typing something
> BomB

I'm not able to reproduce this, but maybe I'm misunderstanding some of the steps. When you say 'Change the system language to Persian' do you mean 'choose the Persian keyboard layout' or do you mean "Go to System Preferences -> Language & Text -> Language' and choose Persian as the OS language?

I also need to figure out how to 'open a language file', presumably with WST given the stack trace.
Comment 3 Babak Taraghi CLA 2010-10-18 18:16:47 EDT
Created attachment 181136 [details]
Test case

Open test case or any other PHP script in EClipse,

type something like this:

$foo = 'تم';

type the exact Persian string u c as value for $foo ('j' & 'l' in U.S. keyboard layout).
Comment 4 Scott Kovatch CLA 2010-10-18 18:48:15 EDT
Got it. I had to install the php tools to get this to crash. If you follow the steps described in the php editor you get a crash, exactly as described here. Typing the same text in the Java editor does not crash. Not sure how that will help yet, but at least it's isolated.
Comment 5 Scott Kovatch CLA 2010-10-19 13:03:33 EDT
I'm not able to reproduce this with a 3.7 M2 plus top-of-tree SWT, but I also can't find any changes in the SWT that would have fixed it. It's possible that something above the SWT changed to fix the problem. If you can get a 3.7 build and try to reproduce it there I'd appreciate it.
Comment 6 Babak Taraghi CLA 2010-10-19 17:17:55 EDT
>Got it. I had to install the php tools to get this to crash. If you follow the
>steps described in the php editor you get a crash, exactly as described here.

Yes, its all about a PDT version of Eclipse So u need to have a php editor.

I got a
Eclipse for PHP Developers
Version: Helios Release
Build id: 20100617-1415

And a 
Eclipse for J2EE Developers

But this happened on PDT,
and stack trace ends on some SWT package.
Plus i dont have any idea about other builds.
Comment 7 Scott Kovatch CLA 2011-01-08 19:13:40 EST
For whatever reason this is a 64-bit-only bug. I can't reproduce it in 3.7m4 i386, but it does happen in x86_64. As a short-term workaround, try using the 32-bit builds until we find a fix for this.
Comment 8 Babak Taraghi CLA 2011-01-09 11:23:17 EST
Thanks.
Comment 9 Scott Kovatch CLA 2011-01-20 14:35:11 EST
Crash in native code:

0   libSystem.B.dylib             	0x00007fffffe007c5 __memcpy + 37
1   com.apple.AppKit              	0x00007fff86016a3d _NSLayoutTreeSetLocationForGlyphRange + 1121
2   com.apple.AppKit              	0x00007fff86015b0a -[NSATSLineFragment saveWithGlyphOrigin:] + 2543
3   com.apple.AppKit              	0x00007fff85f7d907 -[NSATSTypesetter _layoutLineFragmentStartingWithGlyphAtIndex:characterIndex:atPoint:renderingContext:] + 7236
4   com.apple.AppKit              	0x00007fff8601132b -[NSATSTypesetter layoutParagraphAtPoint:] + 204
5   com.apple.AppKit              	0x00007fff864b5302 -[NSTypesetter _layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:maxCharacterIndex:nextGlyphIndex:nextCharacterIndex:] + 2637
6   com.apple.AppKit              	0x00007fff86010ada -[NSTypesetter layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:] + 210
7   com.apple.AppKit              	0x00007fff860109c3 -[NSATSTypesetter layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:] + 1238
8   com.apple.AppKit              	0x00007fff8600efa0 -[NSLayoutManager(NSPrivate) _fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] + 1131
9   com.apple.AppKit              	0x00007fff8600e968 -[NSLayoutManager(NSPrivate) _fillLayoutHoleAtIndex:desiredNumberOfLines:] + 211
10  com.apple.AppKit              	0x00007fff8600d5e6 _NSFastFillAllLayoutHolesUpToEndOfContainerForGlyphIndex + 679
11  com.apple.AppKit              	0x00007fff8600d15c -[NSLayoutManager textContainerForGlyphAtIndex:effectiveRange:] + 243
12  com.apple.AppKit              	0x00007fff85f22ba6 -[NSLayoutManager glyphRangeForTextContainer:] + 286
13  libswt-pi-cocoa-3720.jnilib   	0x000000014f34c186 Java_org_eclipse_swt_internal_cocoa_OS_objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSRange_2JJJ + 93
14  ???                           	0x0000000114811c88 0 + 4638973064
15  ???                           	0x0000000114e3bd28 0 + 4645436712
16  ???                           	0x000000013a821f60 0 + 5276573536

I'm going to double-check this doesn't happen in 32-bit. Seems like it should, based on the trace.
Comment 10 Scott Kovatch CLA 2011-01-20 19:30:56 EST
(In reply to comment #9)

> I'm going to double-check this doesn't happen in 32-bit

....but it doesn't. Looking into some ideas to fix it, though.
Comment 11 Babak Taraghi CLA 2011-01-20 19:50:00 EST
Thanks for your effort.
why don't u try Sun virtual box www.virtualbox.org/ to reproduce on a 64-bit OS ?
I can check it out on ubuntu 10.10, ill report the result ASAP.
Comment 12 Scott Kovatch CLA 2011-01-20 21:02:43 EST
Okay, I've found the cause of the crash, but I'm not clear yet why it fails on 64 bits and not 32.

You can boil this down to one line:

<?phpjl

where j and l were typed in via the Persian keyboard layout. Those last two characters merge into one Unicode combined character, but decompose back to two separate values when you call String.getChars(). 

We have two styles here. The first is range 0, 2 and the second is 2, 4. However, the attributed string we are working with has a length of 7, and those two ranges only cover 6 of the characters. 

When we apply font and color attributes to the attributed string the second range doesn't cover the last character in the attributed string, and when that happens, glyphRangeForTextContainer blows up. If I force the second range to be 5 via the debugger, calling glyphRangeForTextContainer doesn't crash.

I think we are doing something incorrectly when we convert the Java string into the NSString. We're just lucky it doesn't blow up on 32 bits, for some reason.
Comment 13 Scott Kovatch CLA 2011-01-20 23:53:33 EST
(In reply to comment #11)
> Thanks for your effort.
> why don't u try Sun virtual box www.virtualbox.org/ to reproduce on a 64-bit OS
> ?
> I can check it out on ubuntu 10.10, ill report the result ASAP.

Thanks, but that won't help. This is strictly a Cocoa problem. I think I know what's going on now; I just need to try some things.
Comment 14 Scott Kovatch CLA 2011-01-21 12:26:57 EST
The problem seems to be creating ranges of attributes that don't fall on the boundaries of composed character sequences. I tried to fix it with rangeOfComposedCharacterSequencesForRange but it didn't help. It looks like we're trying to do the right thing with translateOffset, but we seem to be off by a character on the ranges.
Comment 15 Babak Taraghi CLA 2011-01-21 18:06:35 EST
I dont know if I'm doing good to suggest anything to someone as pro as you, but it will be like u teaching me something here :)

First of all does this have anything todo with NSStringEncoding ? cause this only happens with Persian characters so i thought this may somehow related to the encoding.

And why this cause the system to crash ?!?!? can't we try to catch some exceptions like NSParseErrorException  or NSCharacterConversionException or even Exception itself and at least make the system stable ?

On the other hand, Why can't we increase the second range to be 5 in program as u did through debugger ?

And another thing, Can't we calculate size (length) of the given attributed string (glyphRangeForTextContainer) with something like String.length() and then create a new variable with the actual size of the string ?
Comment 16 Scott Kovatch CLA 2011-02-09 14:32:13 EST
This is IME code, so over to Felipe. See comment #12 and #14 for analysis.
Comment 17 Eclipse Genie CLA 2019-09-01 14:08:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 18 Babak Taraghi CLA 2019-09-02 21:53:48 EDT
Closing this as its not happening with newer versions anymore.